This project has moved. For the latest updates, please go here.

Implementing the "MultipleChoiceFilter"

Sep 26, 2016 at 4:55 PM
Edited Sep 26, 2016 at 6:44 PM
I'm trying to implement a copy of the MultipleChoiceFilter in my applicaiton, and I'm running into an issue where the ListBox in my ControlTemplate isn't getting populated until I edit a cell in my DataGrid.

Is there something simple I could be missing for the initial population? I'm happy to provide any additional information you might need, I'm just not sure what that might be at the moment.

Update: The list also gets populated if I use any other filter.
Sep 27, 2016 at 2:52 PM
What is the ItemsSource of your DataGrid?
Maybe your problem is related to
Sep 27, 2016 at 2:55 PM
The ItemsSource is an IEnumerable on my ViewModel that is populated from an Entity Framework DbContext (so probably an ObservableCollection). It may be related, but I don't think that I'm doing anything out of the ordinary.
Sep 28, 2016 at 6:43 AM
If you (in)directly bind to the DbSet, it might not work since it will not return a collection but a query.
So check if the ViewModel really holds an ObservableCollection or not...
Sep 28, 2016 at 1:59 PM
The ViewModel does definitely have an ObservableCollection, and the Local property on the DbSet is also of type ObservableCollection. See about the DbSet Local property. I await the LoadAsync() method and then set the property on my ViewModel to that Local property.
await _context.Things.LoadAsync();

(DataContext as MainViewModel).Things = _context.Things.Local;

ICollectionView cv = CollectionViewSource.GetDefaultView((DataContext as MainViewModel).Things);
if (cv != null && cv.CanSort)
    cv.SortDescriptions.Add(new SortDescription("UTCTimeStamp", ListSortDirection.Descending));
private ObservableCollection<Thing> _things;

public ObservableCollection<Thing> Things
    get { return _things; }
        _things = (ObservableCollection<Thing>)value;
Maybe the filter is getting tripped up because of the async/await? Is there anything I can call to force the filter to reevaluate the data?
Oct 4, 2016 at 10:49 AM
Maybe your are missing the "NotifyOnTargetUpdated=true" in the binding of the DataGrid.ItemsSource?
Marked as answer by ddreiervs on 10/4/2016 at 9:32 AM
Oct 4, 2016 at 4:32 PM
It looks like adding NotifyOnTargetUpdated to the binding got it working. It would be great if you could add that to the documentation somewhere. I'm sure that I won't be the last person that would find that advice helpful.

I also added and set a global filter and that caused the column filters to be updated as well.

Thanks for your help and library!
Oct 5, 2016 at 12:46 PM
Unfortunately I never found the time to write a real documentation, so I added some remarks in the source comments.