我尝试了多种方法,但无法更改菜单项背后的颜色。我预期在MenuItem上方生成某个XAML元素,但我找不到任何东西。如果之前已经回答过这样的问题,我提前道歉,但我真的找不到相关信息。
<Grid>
<DockPanel Margin="0,0,0,715" >
<Menu DockPanel.Dock="Top" Background="#222222" Height="20" VerticalAlignment="Top">
<MenuItem Header="File" Width="80" Background="#333333" Foreground="White">
<MenuItem Header="_New World" Background="#333333" />
<MenuItem Header="_Open World" Background="#333333" />
<MenuItem Header="_Save World" Background="#333333" />
<Separator/>
<MenuItem Header="_Close World" Background="#333333" />
<MenuItem Header="Exit" Background="#333333" />
</MenuItem>
<MenuItem Header="Edit" Width="80" Background="#333333" Foreground="White">
</MenuItem>
</Menu>
<StackPanel Background="AliceBlue"></StackPanel>
<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="34" Height="34"/>
</DockPanel>
</Grid>
<Application.Resources>
<Style TargetType="{x:Type StackPanel}"/>
<Style TargetType="{x:Type Menu}">
<Setter Property="Background" Value="#222222"></Setter>
<Setter Property="VerticalAlignment" Value="Top"></Setter>
<Setter Property="Height" Value="20"/>
<Setter Property="DockPanel.Dock" Value="Top"/>
</Style>
<Style TargetType="{x:Type Grid}"/>
</Application.Resources>