Ivan
Ivan

Reputation: 649

WPF and treeview: tricks with Items

I have some questions about treeview in WPF.

  1. How can I change header of selected item?
  2. How can I add child Items to selected item?

Upvotes: 0

Views: 342

Answers (2)

thumbmunkeys
thumbmunkeys

Reputation: 20764

Robert is right, you should use MVVM and data binding. The tutorial that IMHO explained it best is here

Upvotes: 2

Robert Rossney
Robert Rossney

Reputation: 96702

Use MVVM. In your HierarchicalDataTemplate, bind Header and ItemsSource to properties in your view model which implement change notification. Now any changes you make to those properties will be reflected in the TreeView.

If you're not using MVVM and data binding to populate the TreeView, you're wasting a lot of effort.

Upvotes: 3

Related Questions