开发者

WPF - Count of Collection stays unchanged even after Filtering

I have a ListBox which is bound to a collection of type Photos called photos.

I have a Label which is bound to the Count property of photos.

at the initial state the photos contains 8 items, and the label shows that. Even after a filtering that makes the items shown in the ListBox to be 5 the label which bound to the photos.Count property still shows 开发者_StackOverflow社区8 items (ofcourse cause the photos collection did not changed, only the default CollectionView was chagned.

how do i make my label to be bound to the Count property of the photos default CollectionView?

I know how to make this with a CollectionViewSource that i create (as a resource for example) but i would like to know how i bind to the count of the Default Collection View.

thanks


instead of binding count to initial source bind it to listbox items.count using element binding... some thing similar to this

<StackPanel>
        <ListBox Name="listBox1"/>
        <TextBlock Text="{Binding ElementName=listBox1,Path=Items.Count}"/>      
    </StackPanel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜