原文: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中的菜单模板的更多相关文章

  1. WPF 中获取DataGrid 模板列中控件的对像

    WPF 中获取DataGrid 模板列中控件的对像 #region 当前选定行的TextBox获得焦点 /// <summary> /// 当前选定行的TextBox获得焦点 /// &l ...

  2. WPF中的数据模板(DataTemplate)(转)

    原文地址 http://www.cnblogs.com/zhouyinhui/archive/2007/03/30/694388.html WPF中的数据模板(DataTemplate)        ...

  3. WPF中的数据模板(DataTemplate)

    原文:WPF中的数据模板(DataTemplate) WPF中的数据模板(DataTemplate)                                                   ...

  4. WPF中的数据模板使用方式之一:ContentControl、ContentTemplate和TemplateSelector的使用

    在WPF中,数据模板是非常强大的工具,他是一块定义如何显示绑定的对象的XAML标记.有两种类型的控件支持数据模板:(1)内容控件通过ContentTemplate属性支持数据模板:(2)列表控件通过I ...

  5. wpf中的数据模板

    wpf中的模板分为数据模板和控件模板,我们可以通过我们自己定制的数据模板来制定自己想要的数据表现形式.例如:时间的显示可以通过图片,也可以通过简单数字表现出来. 例如: (1)先在Demo这个命名空间 ...

  6. 如何在WPF中定义窗体模板

    参考网址:https://www.cnblogs.com/chenxizhang/archive/2010/01/10/1643676.html可以在app.xaml中定义一个ControlTempl ...

  7. 在WPF中获取DataGridTemplateColumn模板定义的内容控件

    xaml格式描述: <DataGrid Name="dataGrid" Grid.Row="1" ItemsSource="{Binding}& ...

  8. 在WPF中获取DATAGRIDTEMPLATECOLUMN模板定义的内容控件(转载)

    原文:http://www.cnblogs.com/eric_ibm/p/3772516.html xaml格式描述: <DataGrid Name="dataGrid" G ...

  9. WPF中Expander的用法和控件模板详解

    一.Expander的用法 在WPF中,Expander是一个很实用的复合控件,可以很方便的实现下拉菜单和导航栏等功能.先介绍简单的用法,而后分析他的控件模板. <Window.Resource ...

随机推荐

  1. PatentTips - Modified buddy system memory allocation

    BACKGROUND Memory allocation systems assign blocks of memory on request. A memory allocation system ...

  2. irms模拟数据生成及数据分析 分类: H_HISTORY 2015-03-06 14:17 212人阅读 评论(0) 收藏

    一.数据准备 1.每天生成随机一个文本,每小时向文本中追加2次数据,每次10万条 随机数据生成: 2,32  * * * *  bash /mnt/jediael/irms/signalGenerat ...

  3. 【record】9.24..10.1

    因为参加比赛所以做得比较少了

  4. Apache+tomcat的整合 分类: C_OHTERS 2014-05-07 15:08 293人阅读 评论(0) 收藏

    http://blog.csdn.net/stefyue/article/details/6918542 为什么要做这个整合呢?当然,首先想到是就是Apache和Tomcat的区别.正因为有区别,有各 ...

  5. centos-mirrors

    http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/Packages/ http://mirrors.aliyun.com/centos/7.2.1 ...

  6. 【t035】收入计划

    Time Limit: 1 second Memory Limit: 32 MB [问题描述] 高考结束后,同学们大都找到了一份临时工作,渴望挣得一些零用钱.从今天起,Matrix67将连续工作N天( ...

  7. DATAGUARD在做SWITCHOVER切换时遇到问题总结

    1.主库在进行物理主备库角色转换的时候遇到ORA-01093错误 SQL> select switchover_status from v$database;   SWITCHOVER_STAT ...

  8. [TypeScript] Create random integers in a given range

    Learn how to create random integers using JavaScript / TypeScript. /** * Returns a random int betwee ...

  9. Android JNI编程(八)——体验AS2.2.2编写Jni程序、Java调C、C调Java函数、将C代码中的Log打印至Logcat

    版权声明:本文出自阿钟的博客,转载请注明出处:http://blog.csdn.net/a_zhon/. 目录(?)[+] 不得不说在AS2.2以上的版本进行开发就一个字——爽,在2.0上使用jni出 ...

  10. BigDecimal 舍入模式(Rounding mode)介绍

    BigDecimal 舍入模式(Rounding mode)介绍 什么样的经历,才能领悟成为架构师? >>>   1 RoundingMode介绍 package java.math ...