WPF中的菜单模板
原文:WPF中的菜单模板
资源字典代码如下:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--Menu控件模板-->
<ControlTemplate x:Key="mycontroltemplate" TargetType="{x:Type Menu}">
<Border Margin="2"
Background="Chocolate"
CornerRadius="3"
SnapsToDevicePixels="True">
<ItemsPresenter/>
</Border>
</ControlTemplate>
<!--MenuItem控件模板-->
<ControlTemplate x:Key="mymenuitemtemplate"
TargetType="MenuItem">
<Border Name="Border">
<Grid>
<ContentPresenter
Margin="10"
ContentSource="Header"
RecognizesAccessKey="True"/>
<Popup
AllowsTransparency="True"
Name="Popup"
Placement="Top"
IsOpen="{TemplateBinding IsSubmenuOpen}"
Focusable="False"
PopupAnimation="Slide">
<Border
CornerRadius="30"
Name="SubmenuBorder"
SnapsToDevicePixels="True">
<StackPanel
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Cycle" />
<Border.Background>
<DrawingBrush>
<DrawingBrush.Drawing>
<GeometryDrawing Brush="YellowGreen">
<GeometryDrawing.Geometry>
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="20" RadiusY="20"/>
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="10" RadiusY="10"/>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.Background>
</Border>
</Popup>
</Grid>
</Border>
<!--可有可无________________________________________________________________________________-->
<!--<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="Popup" Property="PopupAnimation" Value="None"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Border" Property="Background"
Value="Transparent"/>
<Setter TargetName="Border" Property="BorderBrush"
Value="Transparent"/>
</Trigger>
<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="True">
<Setter TargetName="SubmenuBorder" Property="CornerRadius" Value="0,0,4,4"/>
<Setter TargetName="SubmenuBorder" Property="Padding" Value="0,0,0,3"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>-->
<!--可有可无________________________________________________________________________________-->
</ControlTemplate>
</ResourceDictionary>
窗体XAML代码如下:
<Window x:Class="WPF中的菜单模板.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyDictionary/MyDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<DockPanel>
<Menu DockPanel.Dock="Bottom"
Template="{StaticResource mycontroltemplate}">
<MenuItem Header="开始">
<MenuItem Header="开始"></MenuItem>
<MenuItem Header="开始"></MenuItem>
<MenuItem Header="开始"></MenuItem>
<MenuItem Header="开始"></MenuItem>
</MenuItem>
<Menu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Template" Value="{StaticResource mymenuitemtemplate}"/>
</Style>
</Menu.ItemContainerStyle>
</Menu>
<Popup></Popup>
</DockPanel>
</Window>
WPF中的菜单模板的更多相关文章
- WPF 中获取DataGrid 模板列中控件的对像
WPF 中获取DataGrid 模板列中控件的对像 #region 当前选定行的TextBox获得焦点 /// <summary> /// 当前选定行的TextBox获得焦点 /// &l ...
- WPF中的数据模板(DataTemplate)(转)
原文地址 http://www.cnblogs.com/zhouyinhui/archive/2007/03/30/694388.html WPF中的数据模板(DataTemplate) ...
- WPF中的数据模板(DataTemplate)
原文:WPF中的数据模板(DataTemplate) WPF中的数据模板(DataTemplate) ...
- WPF中的数据模板使用方式之一:ContentControl、ContentTemplate和TemplateSelector的使用
在WPF中,数据模板是非常强大的工具,他是一块定义如何显示绑定的对象的XAML标记.有两种类型的控件支持数据模板:(1)内容控件通过ContentTemplate属性支持数据模板:(2)列表控件通过I ...
- wpf中的数据模板
wpf中的模板分为数据模板和控件模板,我们可以通过我们自己定制的数据模板来制定自己想要的数据表现形式.例如:时间的显示可以通过图片,也可以通过简单数字表现出来. 例如: (1)先在Demo这个命名空间 ...
- 如何在WPF中定义窗体模板
参考网址:https://www.cnblogs.com/chenxizhang/archive/2010/01/10/1643676.html可以在app.xaml中定义一个ControlTempl ...
- 在WPF中获取DataGridTemplateColumn模板定义的内容控件
xaml格式描述: <DataGrid Name="dataGrid" Grid.Row="1" ItemsSource="{Binding}& ...
- 在WPF中获取DATAGRIDTEMPLATECOLUMN模板定义的内容控件(转载)
原文:http://www.cnblogs.com/eric_ibm/p/3772516.html xaml格式描述: <DataGrid Name="dataGrid" G ...
- WPF中Expander的用法和控件模板详解
一.Expander的用法 在WPF中,Expander是一个很实用的复合控件,可以很方便的实现下拉菜单和导航栏等功能.先介绍简单的用法,而后分析他的控件模板. <Window.Resource ...
随机推荐
- 洛谷 P3871 中位数
->题目链接 题解: 暴力 经鉴定,此题数据水到没朋友. #include<algorithm> #include<iostream> #include<cstdi ...
- Eclipse查看某个方法被哪些类调用
方法一:打开该类,在类的定义上即类名上,右键-->References--->Project ,就可以查看该类是否被工程中的其他Java文件引用过:但是如果在JSP页面,这个方法查不出来 ...
- swift学习:自定义Log
import UIKit /* 总结:1:let file = (#file as NSString).lastPathComponent,#file获取的是打印所在的文件 的全路径,转成NSStri ...
- php框架排名(Laravel一直第一)
php框架排名(Laravel一直第一) 一.总结 1.Laravel,后面就用这个框架(要用好这个框架,英语得6啊) 2.YII框架和tp框架一样,也是一个国产框架 二.2017世界PHP框架排名T ...
- 【23.48%】【codeforces 723C】Polycarp at the Radio
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 证明的手段 —— 不失一般性的(WLOG)
不失一般性是数学中一个常见的表达.不失一般性(Without loss of generality,缩写:WLOG.WOLOG 或 w.l.o.g.)是数学中一个常见的表达. 如果给不相等的两数,a, ...
- Thinkphp5 Auth权限认证
Thinkphp5 Auth权限认证 一.总结 一句话总结:四表两组关系,一个多对多(权限和用户组之间),一个一对多(用户和用户组之间) 二.Thinkphp5 Auth权限认证 auth类在thin ...
- TI_DSP_SRIO - Doorbell原理
前文介绍到SRIO有多种类型的包,当中包括了Doorbell包,Doorbell是一种高速的通知类型的短消息,包头和携带信息都非常短,用于master srio设备通知slave srio设备,可用于 ...
- SEO那些事:一句代码一键分享网站
这是很久以前就已经写过的笔记了,有一个习惯,每次遇到一个问题,都会进行百度,然后把解决问题的关键点记录下来,有人问我,为什么更新频率如此之快,大部分都是从前积累的知识点. 其实每天工作所涉及的知识点都 ...
- Myeclipse - Web项目转换技巧--处理Java项目、SVN非Web项目问题
喜欢从业的专注,七分学习的态度. 概述 对于Java调试,使用Eclipse习惯性的使用Junit调试,使用Myeclipse习惯性的将项目转成Web项目在Tomcat或Weblogic中调试,在My ...