Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: CheckListBox filtering with ICollectionView

$
0
0
The CheckListBox ItemsSource is bound to a CollectionView so I can use a textbox to apply filtering. However, when an item that was checked is removed from the view by the text filter it is no longer checked when the filter is removed and the item returns. Here is how the CheckListBox binding is setup, 'UnitListView' is the CollectionView and CheckedUnits is just a list.
<xctk:CheckListBox Margin="50 5 50 50"
                               ItemsSource="{Binding UnitListView}"
                               SelectedItemsOverride="{Binding CheckedUnits}"
                               Command="{Binding CheckedCommand}"/>
I added the command to determine if it executes when the filter is applied. The result was that it only executes when an item is checked (when I click the item), not when items are filtered. The text filter is straight forward and shown below:
        private bool TextFilter(object item)
        {
            Console.WriteLine(FilterString);
            if (String.IsNullOrEmpty(FilterString))
                return true;
            else
                return ((item as UnitModel).ToString().IndexOf(FilterString, StringComparison.OrdinalIgnoreCase) >= 0);
        }
Any insight into this? I am new to ICollectionView, is there something there that I am missing?

Viewing all articles
Browse latest Browse all 2157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>