I wanna to bind two or more class of data as TreeViewItem. For a directly example: file and folder contained in another folder but you don't know the struct at first. I wanna realise it with WPF treeview. But treeview can just bind only one type of node with HierarchicalDataTemplate(Such as my code).
<DockPanel SizeChanged="FrameworkElement_OnSizeChanged">
<DockPanel.Resources>
<HierarchicalDataTemplate x:Key="NodeDataTemplate"
DataType="{x:Type sideList:SideListNode}"
ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" x:Name="DisplayName" Text="{Binding DisplayName}" ></TextBlock>
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=}" Value="0">
<Setter TargetName="DisplayName" Property="Background" Value="Red">
</Setter>
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</DockPanel.Resources>
<TreeView
x:Name="SideList" DockPanel.Dock="Left" MinWidth="200" MaxWidth="250" Background="Aqua"
ItemTemplate="{StaticResource NodeDataTemplate}">
</TreeView>
But of course there some different between folder and file. Some distingct property for each others. Now we need bind two type for create nodes. One for file and one for folder. How we can do that?