如何在WPF中向菜单项添加矩形?
我正在用矩形自定义菜单项。我需要删除默认菜单项中的所有特征,并将自定义矩形添加到菜单中。我不确定菜单项的哪个属性应该被覆盖?有什么帮助吗?定义如下模板:如何在WPF中向菜单项添加矩形?,wpf,xaml,Wpf,Xaml,我正在用矩形自定义菜单项。我需要删除默认菜单项中的所有特征,并将自定义矩形添加到菜单中。我不确定菜单项的哪个属性应该被覆盖?有什么帮助吗?定义如下模板: <ControlTemplate x:Key="customMenuItem" TargetType="{x:Type MenuItem}"> <WrapPanel Background="Gray" Margin="3"> <Rectangle Fill="Blac
<ControlTemplate x:Key="customMenuItem" TargetType="{x:Type MenuItem}">
<WrapPanel Background="Gray" Margin="3">
<Rectangle Fill="Black" Width="16"/>
<ContentPresenter Content="{TemplateBinding Header}"/>
</WrapPanel>
</ControlTemplate>
然后将其用作任何菜单项的模板
<Menu>
<MenuItem Template="{StaticResource customMenuItem}" Header="some text"/>
</Menu>