I have a TreeView which contains items populated by a HierarchicalDataTemplate. I am trying to get to a property in the TreeView's DataContext from inside the HierarchicalDataTemplate. Can someone help? Here is what I tried in the HierarchicalDataTemplate:
<HierarchicalDataTemplate x:Key="MyTopLevel"
ItemTemplate="{StaticResource LowerLevelTemplate}"
ItemsSource="{Binding LowerLevel}">
<TextBlock Text="{Binding Name, Mode=OneWay}" ToolTip="{Binding Name, Mode=OneWay}">
<TextBlock.ContextMenu>
<ContextMenu x:Name="MyContextMenu">
<MenuItem Header="{Binding DataContext.Test, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</HierarchicalDataTemplate>