I am using a WPF treeview with couple of heierachical datatemplates. Treeview has a drag drop capability.
Can someone please help me to get the selected TreeViewItem’s Header section height (Actual Height). If I get the selected items ActualHeight(TreeViewItem.ActualHeight) then it will give the height with the children. But I want is only the Header elements height.
I achived this by using a VisualTree search to find a control (border) inside the data template which covers the entire header. What I want is a more faster way of doing this (Faster than the visual tree search) since I am doing this inside a DragOver event of the treeview.
TreeViewItem has a named part for the header called PART_Header, and you can use ControlTemplate.FindName to get a reference to that part. Note that it could be missing if the control template has been changed and the new template does not actually render the header.
(The Border you are currently using is probably the parent of this element, so you may get slightly different results).