How can I change GridViewItems visibility using property binding?
I can't create another ObservableCollection to filter the one I am using as ItemsSource. I tried to use GridView.ItemContainerStyle to change the GridViewItem style but it seems that it does not work with binding (although it works if I set the value to Collapsed).
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource booleanToVisibilityConverter}}" />
</Style>
</GridView.ItemContainerStyle>
I also tried to use a DataTemplateSelector. I can hide items with binding but then there are gaps on my GridView because the ItemContainer is still there and does not collapse.
I need the GridView items to be collapsed and not just hidden.
EDIT: Why do I want to get rid of filtered ObservableCollections?
I am trying to mirror 2 GridViews and 1 ListView with the same ItemsSource and SelectedItem both binded with my ViewModel properties Items and Current.
Without filters it works as I expect without SelectionChanged events, but with only Two-Way Binding.
But those GridView/Listview must have some differences such as the available items for selection and its DataTemplates. So I am using filtered collections that brought me problems.
For example:
GridView1has Items 1, 2 and 3GridView2has only Items 1 and 3- I select Item 1 of
GridView1 - I select Item 2 of
GridView1
When I select Item 1 it also gets selected on GridView2. Good for now. When I select Item 2, Item 1 maintains selected on GridView2. GridView2 should now be without selection but if I force it to it will always deselect Item 2 of GridView2 since SelectedItem of both is Two-Way binded.
I hope this is understandable because English is not my native language.