I have a list of controls, where each control has ZIndex property:
class WizardControl : INotifyPropertyChanged
{
public int ZIndex { get; set; /* set emits PropertyChanged event */}
}
class WizardStep
{
ObservableCollection<WizardControl> Controls { get; set; }
}
class Wizard
{
ObservableCollection<WizardStep> Steps { get; set; }
}
I also have a TreeView
using HierarchicalDataTemplate
, where each WizardStep
has a tree-node with all WizardControl
as tree leaves.
Now I would like to sort the controls by their ZIndex. I found a solution using custom Converter
(http://stackoverflow.com/a/5730402/69868), which works fine as long as ZIndex does not change.
When the ZIndex changes, the sorted CollectionView does not emit CollectionChanged event and the GUI does not pick the change of order.
My question: how to create a sorted collection that will emit correct events when items are reordered due to change in sort-by values?