How do I specify a HierarchicalDataTemplate for a templated type?
Sometimes you might have to specify a HierarchicalDataTemplate for a templated type. If so, you can only do this in code-behind. (If you have to do this in XAML try wrapping that template type within a non-templated dummy type.)
For example, if you have to do something like this:
The above wouldn’t compile because the XAML compiler doesn’t support this.
So, you will have to do this in code-behind instead:
Note that the above code also illustrates how to add a HierarchicalDataTemplate resource to the Resources list without specifying a key.