WPF HiercharchicalDataTemplate.DataType: How to react on interfaces?

后端 未结 3 467
有刺的猬
有刺的猬 2021-01-14 18:44

Problem

I\'ve got a collection of IThings and I\'d like to create a HierarchicalDataTemplate for a TreeView. The straightfor

3条回答
  •  情书的邮戳
    2021-01-14 19:16

    The reason for this is that the default template selector supports only concrete types, not interfaces. You need to create a custom DataTemplateSelector and apply it to the ItemTemplateSelector property of the TreeView. I can't find the URL where I found an example of it, but hopefully with this info, you can Google it.

提交回复
热议问题