AutoExpand treeview in WPF

前端 未结 5 2065
悲哀的现实
悲哀的现实 2021-02-06 21:04

Is there a way to automatically expand all nodes from a treeview in WPF? I searched and didn\'t even find an expand function in the treeview property.

Thanks

5条回答
  •  孤独总比滥情好
    2021-02-06 21:24

    You can set ItemContainerStyle and use IsExpanded property.

    
       
          
             
                
             
             
                
             
             
                
             
          
       
    
    

    If you need to do this from code, you can write viewmodel for your tree view items, and bind IsExpanded property to corresponding one from model. For more examples refer to great article from Josh Smith on CodeProject: Simplifying the WPF TreeView by Using the ViewModel Pattern

提交回复
热议问题