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?
views:
107answers:
2
+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 DataTemplate
s 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 DataTemplate
s can be as complex as needed to display the various classes present in the TreeView
.
HTH, Kent
Kent Boogaart
2009-04-14 15:42:26
thanks ... looks great
Marcel Benthin
2009-04-14 16:03:49
nice ... didn't know that one. But i think that would be to much for my needs.
Marcel Benthin
2009-04-15 10:26:43