我有一个WPF菜单:

XAML:
<Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Background="#FF171616" CornerRadius="5" BorderBrush="DarkGray" BorderThickness="5" Opacity="0.0">
<StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" Margin="5,4,5,4"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>我是否使用了正确的x:Type ContextMenu来更改下拉可视化?菜单项的视觉效果被改变了,因为我已经手动更改了样式。但这是我想要应用视觉效果的上下文下拉列表。
如何修改上下文下拉菜单本身?
这是我想要的油漆样本:

发布于 2014-05-29 01:10:34
要修改菜单的样式,您需要覆盖菜单样式。如下所示:
<Style TargetType="{x:Type Menu}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#FF171616" />
</Style>编辑:如果你愿意,你也可以修改整个模板。但我认为这些属性应该能让你得到你想要的可视化效果。
https://stackoverflow.com/questions/23917597
复制相似问题