WPF:如何在MenuItem子菜单的模板或样式中取消Ico样式设置?

静水深流的流 2017-10-18 09:02:29
下图的箭头所指之处是一个容器,容器中添加了若干控件。
WPF的MenuItem控件中如何实现如下截图的效果?请大神解答,谢谢。


我的xaml测试如下,无法实现上述截图中的效果,无法去掉MenuItem子菜单的Ico显示区域:
<Window.Resources>
<!--MenuItem控件模板-->
<ControlTemplate x:Key="mymenuitemcontroltemplate" TargetType="{x:Type MenuItem}">
<Border>
<Grid>
<!--<ContentPresenter ContentSource="Header"/>-->
<!--<Popup IsOpen="{TemplateBinding IsSubmenuOpen}" Placement="Bottom" AllowsTransparency="True">
<Border Margin="1" Background="Chocolate">
<StackPanel IsItemsHost="True">
</StackPanel>
</Border>
</Popup>-->
<StackPanel IsItemsHost="True">
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
</Window.Resources>
<Grid>
<Menu HorizontalAlignment="Left" Height="19" Margin="50,50,0,0" VerticalAlignment="Top" Width="38">
<MenuItem Header="1111">
<MenuItem Header="22222">
<MenuItem Template="{StaticResource mymenuitemcontroltemplate}" Height="50">
<Grid Height="50">
<WrapPanel >
<Button Content="111111"/>
<Button Content="555555"/>
</WrapPanel>
</Grid>
</MenuItem>
</MenuItem>
</MenuItem>
</Menu>
</Grid>

...全文
2238 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
一个破人 2017-10-19
  • 打赏
  • 举报
回复
模板绑定位置不对啊,给每个MenuItem都设置模板试试!
静水深流的流 2017-10-18
  • 打赏
  • 举报
回复
难道无法更改MenuItem的模板?

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧