当我右键单击数据网格时,我有上下文菜单。它完全符合我的要求,但问题是,这种菜单样式会覆盖现有的菜单样式。我只想将 ControlTemplate 应用于此菜单。请帮忙。
这是 XAML
<ContextMenu x:Key="cellContextMenu">
<MenuItem Header="Insert symbol" Margin="0,0,0,0" HorizontalContentAlignment="Right">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<wpfc:SymbolController x:Name="dgSymbolControl" Width="400" Height="400" value="{Binding Path=SelectedSymbolItem, Mode=TwoWay, diagnostics:PresentationTraceSources.TraceLevel=High}"></wpfc:SymbolController>
<TextBlock FontFamily="DYMObvba" Text="{Binding ElementName=dgSymbolControl, Path=value}" />
</StackPanel>
</MenuItem>
</ContextMenu>
<ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
<Grid>
<Border Name="Check" Visibility="Collapsed" Margin="0,0,0,0"></Border>
<ContentPresenter Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/>
</Grid>
</ControlTemplate>
这是应用菜单的代码:
eCell.ContextMenu = (ContextMenu)FindResource("cellContextMenu");
谢谢迪