views:

107

answers:

2

I got a TreeView containing different objects from different classes. Now I want to build a propertypanel, which shows up different content, depenting on what object/class is selected in the TreeView. What is the best way to build such panel? Differnt panels and collapsing panels depending on the selection(Whould make implementing the ObserverPattern this easier for me?)? Or an other approach?

+1  A: 

I would bind the property panel (which could be just a ContentControl) to the SelectedItem in the TreeView:

<ContentPanel Content="{Binding SelectedItem, ElementName=_treeView}"/>

Then I would use DataTemplates to show the correct panel for each class of item you have:

<DataTemplate DataType="{x:Type local:SomeClass}">
    <Label>This is displayed for SomeClass</Label>
</DataTemplate>

<DataTemplate DataType="{x:Type local:SomeOtherClass}">
    <Label>This is displayed for SomeOtherClass</Label>
</DataTemplate>

Obviously your DataTemplates can be as complex as needed to display the various classes present in the TreeView.

HTH, Kent

Kent Boogaart
thanks ... looks great
Marcel Benthin
A: 

Do you mean a property grid?

Carra
nice ... didn't know that one. But i think that would be to much for my needs.
Marcel Benthin