We are currently evaluating RadTreeView and we have an MVVM sorting scenario that is not working correctly. Note that everything was working fine with another treeview that was just a standard ItemsControl with some multi-selection capabilities added.
Certain nodes in the tree are sorted by adding SortDescriptions to ListCollectionView and the sorting works fine when items are added or removed.
The problem I'm having is with updating the sort order in reaction to changes made to the backing viewmodel objects. I am trying to leverage IEditableCollectionView as described here: http://drwpf.com/blog/category/collections/.
In the code below, treeViewItem is the RadTreeViewItem that is attached to the modified object:
IEditableCollectionView ev = treeViewItem.ParentTreeView.Items;
if (ev != null)
{
// this forces the parent to re-sort in response to the sort field changing
ev.EditItem(treeViewItem.DataContext);
ev.CommitEdit();
}
The code compiles & runs, but the tree is not updated with the new sort order.
If I instead call refresh, the treeview is updated with the correct sort order:
treeViewItem.ParentTreeView.Items.Refresh();
However, the tree can have hundreds of items in it and I really don't want to call Refresh for performance reasons.
Is there a way to get this scenario working? This is the one thing preventing us from being able to use RadTreeView instead of the TreeView we were using before.
Certain nodes in the tree are sorted by adding SortDescriptions to ListCollectionView and the sorting works fine when items are added or removed.
The problem I'm having is with updating the sort order in reaction to changes made to the backing viewmodel objects. I am trying to leverage IEditableCollectionView as described here: http://drwpf.com/blog/category/collections/.
In the code below, treeViewItem is the RadTreeViewItem that is attached to the modified object:
IEditableCollectionView ev = treeViewItem.ParentTreeView.Items;
if (ev != null)
{
// this forces the parent to re-sort in response to the sort field changing
ev.EditItem(treeViewItem.DataContext);
ev.CommitEdit();
}
The code compiles & runs, but the tree is not updated with the new sort order.
If I instead call refresh, the treeview is updated with the correct sort order:
treeViewItem.ParentTreeView.Items.Refresh();
However, the tree can have hundreds of items in it and I really don't want to call Refresh for performance reasons.
Is there a way to get this scenario working? This is the one thing preventing us from being able to use RadTreeView instead of the TreeView we were using before.