Kushal Waikar
Kushal Waikar

Reputation: 2994

XCeed DataGrid for WPF v4.x: Accessing Excel like filters

I am using XCeed DataGrid for WPF 4.x. I have created excel like drop down filters using view's ItemProperties.

  1. Let’s say there is a single column in data grid with values 1,1,0,1.
  2. Now I apply excel like filter enter image description here
  3. Now there will be rows with value 1 in the data grid.
  4. Question: How to find values checked in this drop down(read)? And also how to set these check boxes from code behind(write)?

Main purpose: To retain previous excel like filter applied by user when data grid item source is changed. [In case of above example after #2, if I change items source from {1,1,0,1} to {0,0,0,0} then user should not be able to see even a single row in grid]

Upvotes: 2

Views: 1415

Answers (1)

Dahdahm
Dahdahm

Reputation: 513

This can be done by accessing the AutoFilterValues collection on the underlying DataGridCollectionView in which the DataGridControl is bound.

Lets say your DataGridControl instance is "grid"

read:

( grid.ItemsSource as DataGridCollectionView ).AutoFilterValues[ "column header" ]

write: ( grid.ItemsSource as DataGridCollectionView ).AutoFilterValues["column header"].Add(0);

Upvotes: 1

Related Questions