wpf menuitem 简约显示的 template样式
<ControlTemplate x:Key="MenuItemControlTemplate1" TargetType="{x:Type MenuItem}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderThickness="0,0,0,0.7" BorderBrush="White"/>
<DockPanel>
<TextBlock x:Name="TextContent" HorizontalAlignment="Center">
<ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</TextBlock>
</DockPanel>
<Popup x:Name="PART_Popup" AllowsTransparency="True" Margin="0" Focusable="False" HorizontalOffset="1" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom" VerticalOffset="-1">
<Themes:SystemDropShadowChrome x:Name="Shdw" Color="#535865">
<Border x:Name="SubMenuBorder" BorderBrush="#FF959595" BorderThickness="0">
<ScrollViewer x:Name="SubMenuScrollViewer" Margin="0" Padding="0" BorderThickness="0" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled" ShowGridLines="True" Background="#535865">
<StackPanel IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Cycle" Width="100"/>
</Grid>
</ScrollViewer>
</Border>
</Themes:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="True">
<Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter Property="Foreground" TargetName="TextContent" Value="#54FFFF"/>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="Red"/>
<Setter Property="BorderThickness" TargetName="OuterBorder" Value="1"/>
</Trigger>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
效果图如下

wpf menuitem 简约显示的 template样式的更多相关文章
- WPF 文字换行TextWrapping 显示不全用省略号TextTrimming 显示不全弹提示内容ToolTip
原文:WPF 文字换行TextWrapping 显示不全用省略号TextTrimming 显示不全弹提示内容ToolTip [TextBlock] 换行 TextWrapping="W ...
- WPF实现斜纹圆角进度条样式
原文:WPF实现斜纹圆角进度条样式 运行效果: 进度条样式: <!--进度条样式--> <LinearGradientBrush x:Key="ProgressBar.Pr ...
- WPF : ListBox的几种Template属性
原文:WPF : ListBox的几种Template属性 属性名 属性的类名 功能 示例 Template ControlTemplate 定义控件自身的外观.其子元素的布局可以自定义,也可以由It ...
- weex 数据绑定,动态控制组件的显示内容及样式
无论的原生开发还是weex开发,经常会需要我们对一些组件/控件动态赋值,在原生中,我们大家都知道,对控件setText就可以了,那么在weex中呢,我们需要怎么做呢,其实很简单,几行代码就可以搞定!首 ...
- WPF DatePicker默认显示当前日期,格式化为年月日
原文:WPF DatePicker默认显示当前日期 WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里 ...
- WPF 动态添加控件以及样式字典的引用(Style introduction)
原文:WPF 动态添加控件以及样式字典的引用(Style introduction) 我们想要达到的结果是,绑定多个Checkbox然后我们还可以获取它是否被选中,其实很简单,我们只要找到那几个关键的 ...
- AvalonEdit-基于WPF的代码显示控件
AvalonEdit是基于WPF的代码显示控件,项目地址:https://github.com/icsharpcode/AvalonEdit,支持C#,javascript,C++,XML,HTML, ...
- WPF 实现测量显示文本长度
原文:WPF 实现测量显示文本长度 以工具类的方式实现: using System; using System.Windows; using System.Windows.Media; using S ...
- WPF使用MediaElement显示gif图片
原文:WPF使用MediaElement显示gif图片 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/SANYUNI/article/details ...
随机推荐
- Linux系统管理_主题01 :初识Linux_1.6 用好帮助文档man
在 man 界面中,可以使用如下快捷键来进行操作: 上/下箭头 向上/下滚动一行 [Space] 向下翻一页 [Page Down] 向下翻一页 [Page Up] 向上翻一页 [ ...
- 利用Oracle定时任务重置序列
业务需求是:二元化编号规则:RYH+年月+001(开始),按月计算,每月1号重置为001 数据库中已有序列和函数如下: 解决方法:采用Oracle定时任务,每月1号重置该序列从1开始增长,SQL如下: ...
- playbook文件内容解释
[root@node1 playbook]# cat nginx.yml - hosts: test \\主机组,要和nginx.yml在同一个目录下 remote_user: root \\远端执行 ...
- 中crontab定时器里的"2>&1"含义解释
*/1 * * * * /usr/local/php/bin/php posts.php >> /data/logs/audit_bbsposts.log 2>&1 & ...
- centos源码安装mysql5.7
http://blog.csdn.net/langzi7758521/article/details/51435985
- How to remove duplicate lines in a large text file?
How would you remove duplicate lines from a file that is much too large to fit in memory? The dupli ...
- IntelliJ IDEA入门之常用配置以及问题解决(持续更新中)
软件版本: IntelliJ IDEA 2019.1.1(Ultimate Edition) 运行环境: JDK1.8, Tomcat8.0, Maven3.6 我们在学习新的无论是jar包, 框架, ...
- PJzhang:CVE-2019-14287 sudo权限绕过漏洞复现
猫宁!!! 参考链接:Ms08067实验室公众号 sudo 1.8.28版本之前有漏洞. 更新完kali linux,deepin截图工具失效,只能用自带的,不能划重点. 看一下sudo版本,1.8. ...
- 分类并查集[noi2001 食物链]
题目链接:http://cogs.pro:8081/cogs/problem/problem.php?pid=pxNJzxVPU 题目有三种动物,A吃B,B吃C,C吃A 即B是A的食物,A是B的天敌, ...
- python之pandas学习笔记-pandas数据结构
pandas数据结构 pandas处理3种数据结构,它们建立在numpy数组之上,所以运行速度很快: 1.系列(Series) 2.数据帧(DataFrame) 3.面板(Panel) 关系: 数据结 ...