I don't think that there what you're trying to do is supported. You could probably write a custom MarkupExtension
to return a closed generic type, but it looks like you want to use the same DataTemplate
for any NodeViewModel<T> where T : INode
. In this case, WPF would need to support open generics as keys. Which it doesn't.
If that is the case, you're much better off just giving your HierarchicalDataTemplate
a key, and applying it directly to the TreeView
.
Or create a DataTemplateSelector
and check the type of data item to select the proper template.