Display treeviewitem as grid rows in wpf

前端 未结 2 1880
Happy的楠姐
Happy的楠姐 2020-12-08 06:10

Basically in need to achieve something like this using treeview control in wpf: (random picture)


(source: msdn.com)

Where nodes and child n

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 06:41

    If the only problem with your code is that each treeview item renders with different grid column widths, you can try the "share size scope" feature to align them all. In the TreeView control, set Grid.IsSharedSizeScope to true:-

    Then add a SharedSizeGroup to the ColumnDefinitions that should have the same width across all the treeview items (your first column definition has a fixed width anyway, so it's not needed on that):-

    
       
       
       
    
    

    The values are just strings used to "name" the columns, and can be anything you like.

提交回复
热议问题