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 We are using the data grid quite extensively in our application and I came across something I havn't been able to figure out how to solve. We are using the MVVM pattern. If the user sets a specific sorting in the data grid by clicking on the headers and then removes one of the items or adds a new item, the sorting is lost. How can I keep the sorting even if the collection that is bound to the ItemSource is changed? It would be really good if you could provide both instructions and some code that can solve this problem since it is quite urgent. I have emailed you a repro project that illustrates this problem. Best regards |
|
|
Hi Nicklas, Thanks for the repro project. Doing this using MVVM would be a bit tricky, and so I've added a new property to the DataGrid that will enable this behavior for you: ReSortOnCollectionChanged which you'll want to set to true. This will be available in the next nightly build. Without this property, you'd need to keep track of which DataGridColumn is sorted, and then restore the SortDirection property when an item is added or removed. Let me know if you have further questions. -Jason Fauchelle |
|
|
Thank you, it seems to work now. |
|