Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF HierarchicalDataTemplate

Could anyone explain how HierarchicalDataTemplate works

  • What Controls supports HierarchicalDataTemplate?
  • What does a control need to support HierarchicalDataTemplate?

UPDATE

  • What causes the TreeView to render the parent and child nodes when the same HierarchicalDataTemplate in a HeaderedItemsControl only causes the parent to be rendered?
like image 294
thmsn Avatar asked Mar 19 '26 02:03

thmsn


2 Answers

What Controls supports HierarchicalDataTemplate?

All controls that inherit HeaderedItemsControl, such as TreeViewItem or MenuItem

What does a control need to support HierarchicalDataTemplate?

Inheriting from HeaderedItemsControl should be enough

like image 67
Thomas Levesque Avatar answered Mar 22 '26 21:03

Thomas Levesque


Such control needs to be of type HeaderedItemsControl or derived from it. The current framework controls that do are MenuItem, ToolBar and TreeViewItem.

The HeaderedItemsControl overrides the PrepareContainerForItemOverride method and somewhere along that call path checks for HierarchicalDataTemplate.

like image 25
Kenan E. K. Avatar answered Mar 22 '26 21:03

Kenan E. K.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!