Below is the code snippet:
<ResourceDictionary>
* * *
<DataTemplate x:Key="xyzTemplate" DataType="arguments" PresentationTraceSources.TraceLevel="High">
<StackPanel Orientation="Horizontal">
<TextBlock Text="(" VerticalAlignment="Center" Margin="2,0,2,0" FontSize="18"
x:Name="firstbrace" Visibility="Collapsed">
</TextBlock>
<ItemsControl ItemsSource="{Binding}" KeyboardNavigation.IsTabStop="False">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock
开发者_开发百科 FontSize="11" VerticalAlignment="Bottom" Margin="1,0,1,2" Text=" , " Width="auto" Name="Comma" Height="auto" >
</TextBlock>
<ComboBox x:Name="blockCombo" Visibility="Collapsed" ItemsSource="{Binding XPath=.//value}" >
<ComboBox.ContextMenu>
<ContextMenu x:Name="xyzcontextMenu"
DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.DataContext}"
>
<MenuItem
Command="{Binding Path=xyzcommand}"
Header="MenuItem1" >
</MenuItem>
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
I need to set the data context of the context menu "xyzcontextmenu" as the data context of the UserControl.
Please let me know asap how can I achieve this
Thanks, Shwetha
精彩评论