I have a TreeView with ItemsSource being nodes from different types.
class Node
class Folder : Node
class Project : Folder
All 3 classes are defined in the main project. And the xaml I currently use looks like this:
<TreeView Name="ProjectTreeView" SelectedItemChanged="ProjectTreeView_SelectedItemChanged">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type prj:Project}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Path=Name}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type prj:Folder}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Path=Name}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type prj:Node}">
<TextBlock Text="{Binding Path=Name}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
What I want to do is have add-in system. In different assemblies I want to define types that will inherit Node or in some cases Folder. And I want these new types to have their own layout in the TreeView. Some of them may have multiple checkboxes or progress bar. The xaml for these new types should be part of the assemblies where the types are defined.
How can I at runtime tell the TreeView what template to use for these new Node types?