I am displaying nodes in a TreeView control, and I am having issues with getting the data to display correctly with generics. More specifically, it seems that WPF is having trouble locating the data template. I'm guessing it is because the x:Type is declared to be NodeViewModel`1
, and the actual type is NodeViewModel< INode>
. However, the XAML will not compile if I try to use NodeViewModel< INode>
.
I've got a HierachialDataTemplate that looks like the following:
<HierarchicalDataTemplate
ItemsSource="{Binding Path=Children}"
DataType="{x:Type viewModels:NodeViewModel`1}">
<TextBlock Text="{Binding Path=Node.NodeDescription}" />
</HierarchicalDataTemplate>
the NodeViewModel is declared as such:
public class NodeViewModel<T> where T : INode
{
public T Node { get {...} set {...} }
}
the nodes interface looks as such:
public interface INode
{
string NodeDescription { get; }
}