I have an object called "TextModel". I defined a HierarchicalDataTemplate for it.
like this:
<HierarchicalDataTemplate DataType="{x:Type local:TextModel}"
ItemsSource="{Binding Children}">
<TextBlock x:Name="TextPresenter"
Text="{Binding Text}"
Style="{StaticResource TextModelStyleMouseOver}" />
</HierarchicalDataTemplate>
This TextModel contained in each TreeViewItem in my TreeView. And, in the code-behind I used VisualTreeHelper.HitTest to get the TreeViewItem that I clicked on, but it's not giving me the TreeViewItem as one of the HitTest results. The HitTest results are: the TextBlock (and Border, Grid and ScrollViewer) - the one from the HierarchicalDataTemplate that I defined.
I've tried to use LogicalTreeHelper.GetParent(textBlockFromTheHitTestResults) but it returned me a null.
Thanks for your attention!