Example : https://ibb.co/x7GqBGp
I inherited TreeListBoxItemAdapter and overridden the GetChildren method.
This is my code:
public override IEnumerable GetChildren(TreeListBox ownerControl, object item)
{
if (item is TreeNode node)
{
if (this.IsAutoSorted)
{
var collection = CollectionViewSource.GetDefaultView(node.Children);
collection.SortDescriptions.Add(new SortDescription("Order", ListSortDirection.Ascending));
collection.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
return collection;
}
else
{
return node.Children;
}
}
else
{
return Enumerable.Empty<ITreeNode>();
}
}
I sort the collection according to Order and Name.
When I add a node, the tree cannot automatically trigger my sorting rules.
I collaspse and then expand, it can trigger the sorting rules.
How to solve this problem so that the sorting is triggered correctly when adding nodes?
Thanks!