<TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding collection_node}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding name_}"> <TextBlock.ContextMenu> </TextBlock.ContextMenu> </TextBlock> </StackPanel> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> public class Node { public string name_ { get; set; } 
  • 3
    or write a converter like stackoverflow.com/questions/5722835/… or expand the observableCollection. It may be possible to connect itemsource via ICollectionView and var desc = new SortDescription (MyProp, ListSortDirection.Ascending); myCollectionView.SortDescriptions.Add (desc); - user2455111

2 answers 2

 collection_node = new ObservableCollection( collection_node.OrderBy(n => n.Name) ); 

    Good example how to use sort.

    https://code.msdn.microsoft.com/windowsdesktop/CollectionView-Tips-MVVM-d6ebb4a7#content

    • one
      I guess this is more an addition to your previous answer than a new one, right? - user227049
    • every decision has a lot of variants
    • one
      Totally agree with you. But, again, don't you think that the link more likely complements your previous answer than is new? - user227049
    • These are 2 different approaches. It all depends on what you need to make as a result. 1 The solution is so fast. 2 This is an approach to solving the problem generically - Leonid Koyler
    • one
      It is better to combine two answers into one. Read more here and here - AK ♦