我有一个背景,其中包含ContextMenu的自定义颜色。我在分隔符中添加(在不同的菜单项之间):
<Separator Background="#EDECEC" Margin="0" ></Separator>
背景颜色为#edecec。但是,我看到一个分隔符,颜色与上下文菜单的其余部分不匹配。它比上下文菜单轻。有办法改变吗?感谢。
答案 0 :(得分:3)
菜单中的Separator
有default Template
忽略Background
,覆盖它使用右键为某些祖先的Resources
添加相应的样式:
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
TargetType="{x:Type Separator}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<!-- ControlTemplate with a TemplateBinding to Background here -->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>