Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1715
Filtering records in the XamDataGrid
posted

I would like to allow the user to filter the records that appear in the data grid. The main way in which I have done this previously is to use the ICollectionView interface. So I am using CollectionViewSource.GetDefaultView(IList<MyRecordClass>) and setting that ICollectionView as the grid's DataSource. It filters the items fine, but I get an error once I click on the record. Basically, if I had selected a record before, and the filtered few does not include the previously selected record, clicking on any other record using the new filter will make the old record show up. Wow. That soudns awful. Let me provide an example to illustrate:

Assume I have two records with one column each: [Record] and [Thing]. I use the ICollectionView interface and set the member as the DataSource. Assume the user initially sees the two records and click on [Record]. He modifies a field and then uses my custom user control to filter the grid. He writes Thing, and the grid now only shows the record [Thing]. The user goes to click on the record. When he does, the value "Thing" turns into "Record". Clearly, not the desired behavior. I have added additional logic that sets the grid's ActiveRecord and ActiveCell to null in the event that the current ActiveRecord is filtered out, but that doesn't seem to help.

 Any ideas? Should I be using some other kind of container for easy filtering ?

 Thanks!

-Szymon

Parents Reply Children
No Data