Reputation: 381
I had another question about binding visibility to a listview item and that got answered.
The issue I have now is I am trying to bind visibility to a property of the listview item but it doesn't seem to work.
Here is my code:
<ListView
ItemsSource="{Binding FooList}"
ItemTemplate="{StaticResource FooTemplate}"
Grid.Row="3">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
and the template:
<DataTemplate x:Key="FooTemplate">
<Grid Background="White" HorizontalAlignment="Stretch">
//template stuff
</Grid>
If I try to set the visibility on the Grid in the template it binds correctly and doesn't display Foo items that it shouldn't, but the space for the container is still there, it's just blank.
If I try to set the visibility binding in the ItemContainer:
<Setter Property="Visibility" Value="{Binding FooVisibility}" />
Then the property FooVisibility never gets called.
What's the appropriate way to hide specific ListView items given that I have an appropriate property that returns a Visibility enum?
Upvotes: 2
Views: 2274