I have a datagrid in which some of the columns I have applied converters, for example to display a name opposed to an id. I would like to be able to filter my datagrid view based off user input. The problem I am running into is that I cannot figure out
how to access the cell contents of the datagrid opposed to the bound object properties. Obviously the user is not going to know the ids to type in, so in my filter I need to check their input with what a particular cells contents are. Here are some snippets
of my code:
.I bind my list to my datagrid...
CollectionViewSource view =
view.Source = worklist;
this.dataGrid1.ItemsSource = view.View;
In my filter I have attempted to retrieve the cell contents a few different ways, all of which return null....
void view_Filter(object sender,
WorklistItem item = (WorklistItem)e.Item;
FrameworkElement f =
DataGridRow row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromIndex(1);
//would like to compare values here
e.Accepted = false;
I noticed in the view_Filter handler, ItemContainer.Status = NotStarted, which I think is why I am getting the null value. If I place GetCellContent inside of the SelectionChangedHandler, I am able to retreive the cell value with no problem. How can I filter
off of cell contents opposed to the bound object props in this scenario, is it even possible? In Addition, is it possible to iterate through rows in the wpf datagrid and get the DataGridRow objects instead of the bound objects?