我已经为菜单项生成了一个自定义控件模板。我修改了IsChecked触发器,以更改处于IsChecked状态的菜单项的外观,以便隐藏glyphPanel且菜单项具有浅蓝色背景。但是我还没有实现的是将背景填充限制为图标,就像在Windows窗体中一样。有人知道怎么做吗?
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Visibility" TargetName="GlyphPanel" Value="Hidden"/>
<Setter Property="Visibility" TargetName="Icon" Value="Visible"/>
<Setter Property="Fill" TargetName="Bg">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#34C5EBFF" Offset="0"/>
<GradientStop Color="#3481D8FF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
...