My issue seems to be one that others have as well, as I've found a few other questions that are similar (e.g. WPF - hiding listbox items). In that particular question/answer, I've gotten further than anything else I've found combined. The problem I'm facing is that when I implement the DataTrigger
as it is in the answer there (slightly modified for ListView
as opposed to ListBox
), I get the proper collapsing of the item, but for certain things, my theme appears to be reverted to the defaults instead of using my ModernUI styling.
Here is what I've added to my ListView
in order to get the collapsed items to truly be collapsed:
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding Visibility}" Value="Collapsed">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
Here is an example of the items filtered before adding the above:
(notice the orange hover of an item that's not supposed to be there)
Here is an example of the items filtered after adding the above:
(notice the hover/selection indicator is now somehow blue, and my text fields no longer size appropriately)
Any help that anyone can provide will be much appreciated, and thanks already for taking the time to read this.
Side-note: Please don't just tell me to use the CollectionView
to filter. I spent the majority of my day yesterday fighting with that, and because of using a BindingList<>
instead of an ObservableCollection<>
, it simply won't work for my situation.
The problem here is that the ModernUI
framework overrides the default style of the ListViewItem
, however you are overriding this:
<Style TargetType="{x:Type ListViewItem}">
Now your style becomes the new default style for a ListViewItem
. To fix this, use the BasedOn
attribute to inherit the ModernUI
style.
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
The code above simply inherits the default ListViewItem
style (which has been overridden by ModernUI
).