0
我有上下文菜單,當我右鍵單擊數據網格。它正是我想要的,但問題是,此菜單樣式覆蓋現有的菜單樣式。我只想將ControlTemplate應用於此菜單。請幫助。wpf ContextMenu樣式
這裏是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");
感謝 迪