It might be a good idea to take a good look at databinding to solve this issue.
You could create model like this:
public class MyViewModel: INotifyPropertyChanged
{
private ObservableCollection<myhierarchicalitem> _myHierarchicalItems;
private MyHierarchicalItem _selectedItem;
public ObservableCollection<myhierarchicalitem> MyHierarchicalItems
{
get { return _myHierarchicalItems; }
set
{
_myHierarchicalItems = value;
RaisePropertyChanged("MyHierarchicalItems");
}
}
public MyHierarchicalItem SelectedItem
{
get { return _selectedItem; }
set
{
_selectedItem = value;
RaisePropertyChanged("SelectedItem");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propertyName)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}</myhierarchicalitem></myhierarchicalitem>
Bind the selected item in the treeview to the model. Also bind the label in the other panel to the same property. Now if you select an item in the treeview, the label for that item will automatically be bound in the other panel.
For a bit more information on databinding I suggest you take a look at the following video:
http://channel9.msdn.com/posts/AdamKinney/Data-Binding-in-Windows-Presentation-Foundation/[
^]