I have following ContextMenu in my xaml:
<ContextMenu ItemsSource="{Binding RSPContextMenuCommands}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="CommandParameter" Value="{Binding}" />
<Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.ShowASPCommand}" />
<Style.Triggers>
</DataTrigger>
<DataTrigger Binding="{Binding SpName}" Value="ASP">
<Setter Property="Header" Value="Show Additional Service Providers" />
<Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.TransferCommand}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContextMenu.ItemContainerStyle>
<ContextMenu.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=PhoneNumber, PresentationTraceSources.TraceLevel=High}" />
</StackPanel>
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu>
where, RSPContextMenuCommands is collection of type Schedule(class). Schedule has PhoneNumber property in it.TransferCommand is at the same level where RSPContextMenuCommands is declared. I am getting ShowASPCommand and TransferCommand but NOT PhoneNumber. I tried various RelativeSource combinations but it didn't work. what should be the proper RelativeSource for it. also tried RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PhoneNumber
workaround. I moved ItemTemplate above ItemContainerStyle.
But still if anyboday can provide me proper documentation for RelativeSource approach. I would really appreciate it. :-)