WPF DataBound treeview expand / collapse

后端 未结 2 2066
北荒
北荒 2020-12-09 16:25

I\'m just trying to find a way to control the expand / collapse of the TreeView nodes through the object they\'re bound to. The object has an IsExpanded

2条回答
  •  鱼传尺愫
    2020-12-09 17:14

    Came up with solution. Really simple:

        
    

    So the style gets the object bound to the TreeViewItem and looks at its IsNodeExpanded attribute and it assigns that value to the TreeViewItem.IsExpanded property. If you add Mode=TwoWay, they'll notify each other (TreeViewItem will tell the object when it has been expanded).

    Thanks!

提交回复
热议问题