Home Forums WPF controls Xceed DataGrid for WPF AutoFiltering question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26230 |

    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.)

    Thanks.

    Marty

    Imported from legacy forums. Posted by Marty (had 2009 views)

    Xceed Support
    Member
    Post count: 5658

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.