Reputation: 311
Can someone tell me how to hide the root node of a TreeView in WPF/Silverlight? I would still like to display hierarchical data and to be able to expand collapse nodes except for the root node (which shouldn't be displayed at all).
Regards,
Xam
Upvotes: 1
Views: 1681
Reputation: 7047
Do you need to have a single root node?
If not you could create all your items at the top level.
<TreeView>
<TreeViewItem Header='First'>
<TreeViewItem Header='sub' />
</TreeViewItem>
<TreeViewItem Header='Second'>
<TreeViewItem Header='sub' />
</TreeViewItem>
<TreeViewItem Header='Third'>
<TreeViewItem Header='sub' />
</TreeViewItem>
</TreeView>
Upvotes: 2
Reputation: 6460
You can create a DataTrigger that makes the root node collapsed
This link may help: http://www.beacosta.com/2006/05/how-can-i-change-way-data-_114702952170041155.html
Upvotes: 0