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


Loss of filter text when loading data


If a datagrid has a filter applied and the datagrid is bound to an observablecolllection, when the observablecollection is recreated. e.g. when loading data from a database.

The filter text is not shown in the header and no results are displayed.

The only way I have found to get the content to be displayed is to type something in the filter textbox and then delete it, this shows all of the data.


tomenglert wrote Mar 29, 2014 at 5:20 PM

I'm not sure if I understand this correctly.
Do you mean the content of the ObservableCollection is reset, or the collection is exchanged with an new one?

Can you provide some sample code?

ncik_w wrote Apr 8, 2014 at 12:35 PM

Sorry for describing very well, here is a code sample of what I mean by recreated:

private ObservableCollection<Foo> _foos;
public ObservableCollection<Foo> Foos
get { return _foos; }
_foos = value;

public void LoadData()
IList<Foo> foos = _database.GetFoos();
Foos = new ObservableCollection(foos);

Calling load data while a filter is enabled removes the filter text, but not filter itself.

wrote Apr 9, 2014 at 2:16 PM

Associated with changeset 30702.

wrote Apr 9, 2014 at 5:49 PM

tomenglert wrote Apr 9, 2014 at 5:53 PM

P.S. This only happens if "AutoGenerateColumns" is on. In this case it's not possible to preserve the filter, since all columns are destroyed and recreated if ItemsSource changes.

coach008 wrote Nov 6, 2015 at 12:35 AM