Hello,
I'm using XamDataTree. The tree to display has nodes of several types. Every node can have subnodes of more than one type. That's why all node type view models are derived from the same base node view model. Because the types differ widely, it is necessary to have separate Layouts for each type to display it. I thought to achive this by using the GlobalNodeLayouts feature. But there is always used the layout for the base class. How can I solve this problem? To show the situation I append a simple example.
Thanks in advance.
DataTreeNodeLayoutBasedOnClass.zip
Hello Josch,
Thank you for contacting Infragistics. I attached a sample below that I believe will help you. It uses a global node layout with a converter and several templates you can configure to customize each level in your tree. Let m know if you have any questions.
1411.Microsofts Tree interfaces.zip
Hello Michael,
thanks, your example works. But unfortunately only the Microsoft tree uses templates. In the XamDataTree version the nodes are directly filled withe an single TextBlock. I've got no idea how to use more complex layouts provided in xaml.
Regards.
Josch
I figured it out. It is very simple and needs no converter:
<Infragistics:XamDataTree Grid.Row="1" ItemsSource="{Binding Mammals}"> <Infragistics:XamDataTree.Resources> <DataTemplate DataType="{x:Type local:Cat}"> <TextBlock Text="{Binding Name}" Background="Gray"/> </DataTemplate> <DataTemplate DataType="{x:Type local:Dog}"> <TextBlock Text="{Binding Name}" Background="Brown"/> </DataTemplate> <DataTemplate DataType="{x:Type local:Mammal}"> <TextBlock Text="{Binding Name}" Background="LightBlue"/> </DataTemplate> </Infragistics:XamDataTree.Resources> <Infragistics:XamDataTree.GlobalNodeLayouts> <Infragistics:NodeLayout Key="Test1" TargetTypeName="IAnimal" > <Infragistics:NodeLayout.ItemTemplate> <DataTemplate> <ContentControl Content="{Binding Data}"/> </DataTemplate> </Infragistics:NodeLayout.ItemTemplate> </Infragistics:NodeLayout> </Infragistics:XamDataTree.GlobalNodeLayouts> </Infragistics:XamDataTree>
I am glad you found a solution. Let me know if you have any additional questions or concerns.