c# - Silverlight: Difficult with Data Binding -


apparently don't understand binding listbox controls data.

here listbox binds property in code-behind:

        <listbox itemssource="favoritefilters"                   x:name="favoritefilterslist"                   visibility="{binding favoritefilters.isempty, converter={staticresource visibilityconverter}}">              <listbox.itemtemplate>                 <datatemplate>                     <my:favoritefilterlink />                 </datatemplate>             </listbox.itemtemplate>         </listbox> 

when this, listbox appears single element populated fallback values, though items source empty. happens no matter set itemssource to, itemssource="totallyinvalidproperty". however, if itemssource empty, listbox disappears.

the code behind:

    public observablecollection<favoritefilter> favoritefilters     {                 {             return plumdata.favoritefilters;         }     } 

plumdata:

    private static observablecollection<favoritefilter> _favoritefilters = new observablecollection<favoritefilter>();     public static observablecollection<favoritefilter> favoritefilters     {                 {             return _favoritefilters;         }     } 

i don't understand why isn't working. however, when in code-behind, works fine:

    void bottomfavoritesbar_loaded(object sender, routedeventargs e)     {         favoritefilterslist.itemssource = favoritefilters;     } 

what doing wrong? i'm using sl4.

off top of head, don't need set binding this:

<listbox itemssource="{binding favoritefilters}"               x:name="favoritefilterslist"               visibility="{binding favoritefilters.isempty, converter={staticresource visibilityconverter}}"> 

note binding keyword.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -