This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello I wonder if it is possible to cache the filters that i've set in a datagrid in the viewmodel and read them back later? The scenario is that we have a datagrid in a usercontrol that we present in a content presenter. If we, for a time, display another view with another viewmodel in the content presenter I want the filters that were set in the datagrid to still be there if we or the user choose to go back to the user control where the datagrid is used. Do you have any suggestions on how to solve this? Best regards |
|
|
Hi Nicklas, The IFilter for a column can be obtained and set via the Filter property on DataGridColumn. One way to cache the filters could be to bind this property on each column to properties in your view model. Let me know if you have further questions about this. -Jason Fauchelle |
|
|
Hello Jason I can't seem to get this to work. I get this when I try to bind the Filter property:
It would be great if you could provide a small working sample with code that I can look at. Best regards |
|
|
Sorry Nicklas, Looks like I got this one wrong. The DataGridColumns are somewhat model objects that don't end up becoming part of the visual tree. As far as I know, this means xaml bindings are not going to work. One option could be to manage the Filter properties from code behind. Another option could be to manage the DataGridColumn objects in the model, and then binding to the Columns collection to add them to the DataGrid. A more advanced option could be to build an attached property that can be bound to the DataGrid which then has logic to manage the Filter properties on the columns. Let me know if you have any questions about the approach(s) you'd like to take. -Jason Fauchelle |
|