开发者

Hide list item in Silverlight 4

开发者 https://www.devze.com 2023-02-11 10:14 出处:网络
I have a silverlight application in which I display items in a list box. I want to hide some items based on a condition, like some value of a string.

I have a silverlight application in which I display items in a list box. I want to hide some items based on a condition, like some value of a string.

My xaml looks like this:

<ListBox
    ItemsSource="{Binding DashboardTypes}" 
    SelectedItem="{Binding SelectedDashboardCategory,Mode=TwoWay}" 
    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    Style="{StaticResource ListBoxStyleAttribute}"
    Margin="2"
    ItemContainerStyle="{StaticRes开发者_如何转开发ource ListBoxItemStyle}" />


You'll need to set up an ItemTemplate to describe your items and then add a binding on that for the Visibility property that controls when items are visible or not. I suspect that you'll need a converter to actually implement the rule for when an item should be visible.

There is a Stack Overflow question that covers something similar but in WPF. It should give you some pointers that will help you in implementing this.

0

精彩评论

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