I’m wondering if I have the correct expectation about how this feature works. If I enable AutoFiltering for all the columns in a grid, I thought that I would see a dropdown arrow for each header, as in Excel. However it appears that to make this happen I will need to write code to make the combobox appear for each column header, and I’d need an event handler to handle the selection of the distinct item and make the filtering occur. Is this correct?
I just had a look at the sample program and I see that the comboboxes were coded separately (and not overlaid on the column header as you see in Excel.)
Imported from legacy forums. Posted by Marty (had 2009 views)
The AutoFilterControl used to display AutoFilterValues/DistinctValues in the column header is located in the ControlTemplate of the ColumnManagerCell. If you want directly access the SelectionChanged, you must redefine the Template in Column.AutoFilterControlStyle and assigned the desired SelectionChanged event handler to the PART_DistinctValuesHost Selector.
A workaround to be notified of modification of the AutoFilterValues without redefining Column.AutoFilterControlStyle is to the register to the INotifyCollectionChanged event for the AutoFilterValues of the desired Column:
// in version 1.3 Column column = dataGrid.Columns[ColumnName];
INotifiyCollectionChanged collectionChanged = column.AutoFilterValues as INotifiyCollectionChanged
// in version 2.0 DataGridCollectionView dataGridCollectionView = dataGrid.ItemsSource as DataGridCollectionView;
INotifiyCollectionChanged collectionChanged = dataGridCollectionView.AutoFilterValues[ColumnName] as INotifiyCollectionChanged;
Imported from legacy forums. Posted by Chris [Xceed] (had 3305 views)