Hi,
I've use xamDataGrid and hav binded to a ListCollectionView with Hierarchical ObservableCollections. I used SortEvaluationMode = "UseCollectionView" for efficient sorting. Now, I don't see sorting happening at the child level where it is an ObservableCollection. What can be done to Sort at the child level using 'UseCollectionView option?
Thanks
Thank you for help with this regards!
Hello RJ,
I am not entirely sure I completely understand what you are looking to achieve in this case? Are you referring to implementation of the INotifyPropertyChanged interface when using the XamDataGrid? If so, this is done in the same way when using a ListCollectionView as when using any other collection type, as shown here: https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx.
I am attaching a sample project that demonstrates a hierarchical structure using ListCollectionView elements along with the FieldLayout-scoped "UseCollectionView" setting for the SortEvaluationMode. This sample project also uses the INotifyPropertyChanged interface and updates the parent-level data items randomly once per second.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thanks Andrew!
Also, how do we get property change notification when using ListCollectionView? Can you share a sample which can help with this?
-Rj
Hello Rj,
I have been investigating into this behavior that you are referring to, and it sounds like to achieve this behavior, you are setting the FieldLayoutSettings.SortEvaluationMode at the XamDataGrid.FieldLayoutSettings level. It may be useful for you to know that each of the FieldLayout elements used to make up a hierarchical structure in the XamDataGrid have a Settings property that takes a FieldLayoutSettings element as well, though.
Knowing the above, I have a couple of recommendations to make on this matter. The first is to set the FieldLayout.Settings.SortEvaluationMode property on your FieldLayouts that represent your ObservableCollection elements to "Default" or "Auto." This will allow the XamDataGrid to carry out the sorting operations on the Fields that are in the scope of your ObservableCollections, while keeping the collection-view sorting on the layout representing your ListCollectionView. The code for this could look like the following:
<ig:FieldLayout> <ig:FieldLayout.Settings> <ig:FieldLayoutSettings SortEvaluationMode="Auto" /> </ig:FieldLayout.Settings></ig:FieldLayout>
The alternative to this is to re-structure your underlying data source to have a hierarchical structure of ListCollectionView elements instead of using ObservableCollections as the underlying collections, as this would allow the setting of SortEvaluationMode to "UseCollectionView" to take effect on the child layouts.