WPF HiercharchicalDataTemplate.DataType: How to react on interfaces?

后端 未结 3 468
有刺的猬
有刺的猬 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:27

    Another alternative (similar to jing's solution): If you only have one type of item, you can set the ItemTemplate directly. Then you don't need to set a key or a datatype.

    In your ViewModel:

    public ObservableCollection Thingies { get; private set; }
    

    In the View:

    
        
            
                    
            
        
    
    

提交回复
热议问题