WPF之工具栏菜单栏功能区。

1,菜单栏,工具栏,状态栏。

        1.1,Menu中可添加菜单分隔条<Separator></Separator>作为分割线,使用Separator可以通过改变其template来自定义,Separator是无焦点的,如果简单的在MenuItem中添加一个textBlock它是可以有焦点的

        1.2,ToolBar没有ToolBarItem,ToolBar会将添加到其中的Button,CheckBox,Combobox样式进行修改.

        1.3,通过附加属性ToolBar.OverFlowMode来设置该项的溢出方式

        1.4,ToolBarTray.Band:确定工具栏放在哪一栏中(最顶部的一栏索引为0),BandIndex属性明确设置一栏中什么位置放置工具栏.

        1.5,ToolBarTray.Orientation:设置工具栏方向      

        1.6,示例:

<Window x:Class="目录样例.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:目录样例"mc:Ignorable="d"Title="MainWindow" Height="350" Width="525"><DockPanel LastChildFill="False"><Menu DockPanel.Dock="Top" ><MenuItem Header="File(_F)"><MenuItem Command="{x:Static ApplicationCommands.Open}"></MenuItem><MenuItem Header="New(_N)" IsChecked="True" x:Name="menuitem01" ></MenuItem><Separator ></Separator><MenuItem Header="Save_S"></MenuItem></MenuItem><MenuItem Header="Eidt_E"><MenuItem Header="撤销"></MenuItem><Separator><Separator.Template><ControlTemplate><Border Padding="10" BorderThickness="1" BorderBrush="Azure" CornerRadius="3"><TextBlock HorizontalAlignment="Center">分割</TextBlock></Border></ControlTemplate></Separator.Template></Separator><Border Padding="10" BorderThickness="1" BorderBrush="Azure" CornerRadius="3"><TextBlock HorizontalAlignment="Center">分割</TextBlock></Border><MenuItem Header="删除" InputGestureText="Ctr+D"></MenuItem></MenuItem></Menu><ToolBarTray DockPanel.Dock="Top"><ToolBar Band="0" ><Button>Line</Button><Button >Rectangle</Button></ToolBar><ToolBar Band="1"><Button>Color</Button><Button >Font</Button></ToolBar><ToolBar Band="0" ><Button>One</Button><Button >Two</Button></ToolBar></ToolBarTray><StatusBar   DockPanel.Dock="Bottom"><!--<StatusBar.ItemTemplate><ItemContainerTemplate><DockPanel></DockPanel></ItemContainerTemplate>--><!--</StatusBar.ItemTemplate>--><StatusBarItem DockPanel.Dock="Right">账号:</StatusBarItem><StatusBarItem DockPanel.Dock="Top" >状态1</StatusBarItem><StatusBarItem  >状态2</StatusBarItem></StatusBar><ToolBarTray Orientation="Vertical" ><ToolBar   ><Button  ><Button.Content><Image Source="/Img/download.png" Width="16" Height="16"></Image></Button.Content></Button><Button Content="Open"></Button><Button Content="Save"></Button><CheckBox FontWeight="Bold">Bold</CheckBox><CheckBox FontStyle="Italic">Italic</CheckBox><CheckBox ><TextBlock TextDecorations="Underline">UnderLine</TextBlock></CheckBox><ComboBox ToolBar.OverflowMode="Never"  Width="80"><ComboBoxItem>10%</ComboBoxItem><ComboBoxItem >20%</ComboBoxItem><ComboBoxItem>30%</ComboBoxItem></ComboBox><Separator></Separator></ToolBar></ToolBarTray></DockPanel>
</Window>

        1.7,效果:

2,功能区

        2.1,使用功能区需要添加程序集System.Windows.Controls.Ribbon。

        2.2,引用程序集:

 xmlns:r="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"

        2.3,为了使快速访问工具栏出现在顶端,需要将默认继承自Window修改为继承自RibbonWindow

 public partial class MainWindow : RibbonWindow{public MainWindow(){InitializeComponent();}}
<r:RibbonWindow x:Class="功能区.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:功能区"mc:Ignorable="d"xmlns:r="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"Title="MainWindow" Height="350" Width="525"><Grid></Grid>
</r:RibbonWindow>

        2.4,示例:

<r:RibbonWindow x:Class="功能区.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:功能区"mc:Ignorable="d"xmlns:r="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"Title="MainWindow" Height="350" Width="525"><Grid><Grid.RowDefinitions><RowDefinition Height="auto"/><RowDefinition Height="279*"/></Grid.RowDefinitions><Ribbon>
<!--定义快速访问工具栏--><Ribbon.QuickAccessToolBar><RibbonQuickAccessToolBar><RibbonButton Label="Cut" SmallImageSource="/Img/cut.png"></RibbonButton><RibbonButton Label="Open" SmallImageSource="/Img/open1.png"></RibbonButton></RibbonQuickAccessToolBar></Ribbon.QuickAccessToolBar><Ribbon.ApplicationMenu><RibbonApplicationMenu SmallImageSource="Img/desktop.png"><RibbonApplicationMenuItem Header="新建" ImageSource="Img/new window.png"></RibbonApplicationMenuItem><RibbonApplicationMenuItem Header="保存" ImageSource="Img/save.png"><RibbonApplicationMenuItem Header="另存" ImageSource="Img/save-as.png"></RibbonApplicationMenuItem></RibbonApplicationMenuItem><RibbonSeparator></RibbonSeparator><RibbonApplicationMenuItem Header="另存" ImageSource="Img/save-as.png"></RibbonApplicationMenuItem></RibbonApplicationMenu></Ribbon.ApplicationMenu><RibbonTab Header="Home" GroupSizeReductionOrder="ClipBoard,Files"><RibbonGroup Header="ClipBoard"><RibbonButton Label="Copy" SmallImageSource="Img/copy.png" LargeImageSource="Img/copy.png"></RibbonButton><RibbonButton Label="Cut" SmallImageSource="Img/cut.png" LargeImageSource="Img/cut.png"></RibbonButton><RibbonButton Label="Paste" SmallImageSource="Img/paste.png" LargeImageSource="Img/paste.png" ToolTipTitle="粘贴" ToolTipDescription="对文档进行粘贴等操作" ToolTipImageSource="Img/cut.png" ToolTipFooterTitle="更多信息" ToolTipFooterDescription="按F1获取更多帮助" ToolTipFooterImageSource="Img/help.png"></RibbonButton></RibbonGroup><RibbonGroup Header="ClipBoard"><RibbonButton Label="Copy" SmallImageSource="Img/copy.png" LargeImageSource="Img/copy.png"></RibbonButton><RibbonButton Label="Cut" SmallImageSource="Img/cut.png" LargeImageSource="Img/cut.png"></RibbonButton><RibbonButton Label="Paste" SmallImageSource="Img/paste.png" LargeImageSource="Img/paste.png" ToolTipTitle="粘贴" ToolTipDescription="对文档进行粘贴等操作" ToolTipImageSource="Img/cut.png" ToolTipFooterTitle="更多信息" ToolTipFooterDescription="按F1获取更多帮助" ToolTipFooterImageSource="Img/help.png"></RibbonButton></RibbonGroup><RibbonGroup Header="Task"><RibbonButton Label="Copy" SmallImageSource="Img/copy.png" LargeImageSource="Img/copy.png"></RibbonButton><RibbonButton Label="Cut" SmallImageSource="Img/cut.png" LargeImageSource="Img/cut.png"></RibbonButton><RibbonButton Label="Paste" SmallImageSource="Img/paste.png" LargeImageSource="Img/paste.png" ToolTipTitle="粘贴" ToolTipDescription="对文档进行粘贴等操作" ToolTipImageSource="Img/cut.png" ToolTipFooterTitle="更多信息" ToolTipFooterDescription="按F1获取更多帮助" ToolTipFooterImageSource="Img/help.png"></RibbonButton></RibbonGroup><RibbonGroup Header="Files"><RibbonButton Label="Copy" SmallImageSource="Img/copy.png" LargeImageSource="Img/copy.png"></RibbonButton><RibbonButton Label="Cut" SmallImageSource="Img/cut.png" LargeImageSource="Img/cut.png"></RibbonButton><RibbonButton Label="Paste" SmallImageSource="Img/paste.png" LargeImageSource="Img/paste.png" ToolTipTitle="粘贴" ToolTipDescription="对文档进行粘贴等操作" ToolTipImageSource="Img/cut.png" ToolTipFooterTitle="更多信息" ToolTipFooterDescription="按F1获取更多帮助" ToolTipFooterImageSource="Img/help.png"></RibbonButton></RibbonGroup></RibbonTab></Ribbon></Grid>
</r:RibbonWindow>

        注明:

                GroupSizeReductionOrder="ClipBoard,Files" ribbonTab中首先被缩小的Group。

                快速访问工具栏。Ribbon.QuickAccessToolBar

        2.5,效果:


 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/10514.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

品鉴中的平衡之美:如何欣赏红酒的口感与风格和谐

品鉴云仓酒庄雷盛红酒的过程&#xff0c;是对其口感与风格和谐的追求和欣赏。平衡是红酒品质的重要标志之一&#xff0c;它体现在红酒的色泽、香气、口感和余味等多个方面。通过欣赏红酒的平衡之美&#xff0c;我们可以更好地领略其精妙之处&#xff0c;感受其带来的美妙滋味。…

【Unity Animation 2D】Unity Animation 2D骨骼绑定与动画制作

一、图片格式为png格式&#xff0c;并且角色各部分分离 图片参数设置 需要将Sprite Mode设置为Single&#xff0c;否则图片不能作为一个整体 1、创建骨骼 1.1 旋转Create Bone&#xff0c;点击鼠标左键确定骨骼位置&#xff0c;移动鼠标再次点击鼠标左键确定骨骼&#xff0c…

大数据面试题第一期*4

题1、HDFS存储机制 &#xff08;1&#xff09;客户端向namenode请求上传文件 &#xff0c;namenode检查目标文件是否已存在 &#xff0c;父目录是否存在。 &#xff08;2&#xff09;namenode返回是否可以上传。 &#xff08;3&#xff09;客户端请求第一个 block上传到哪几个d…

嵌入式C语言高级教程:实现基于STM32的智能健康监测手环

智能健康监测手环能够实时监控用户的生理参数&#xff0c;如心率、体温和活动量&#xff0c;对于健康管理和疾病预防非常有帮助。本教程将指导您如何在STM32微控制器上实现一个基本的智能健康监测手环。 一、开发环境准备 硬件要求 微控制器&#xff1a;STM32L476RG&#xf…

RS3236-3.3YUTDN4功能和参数介绍及PDF资料

RS3236-3.3YUTDN4功能和参数介绍及PDF资料-公司新闻-配芯易-深圳市亚泰盈科电子有限公司 品牌: RUNIC(润石) 封装: XDFN-4-EP(1x1) 描述: 带过温保护 输出类型: 固定 最大输入电压: 7.5V 输出电压: 3.3V 最大输出电流: 500mA RS3236-3.3YUTDN4 是一款低压差线性稳压器&#x…

PX4FMU和PX4IO最底层启动过程分析(下)

PX4FMU和PX4IO最底层启动过程分析&#xff08;下&#xff09; PX4FMU的系统启动函数为nash_main(int argc,char *argv[]) PX4IO的系统启动函数为nash_start(int argc,char *argv[]) PX4FMU启动函数nash_main(int argc,char *argv[]) 首先分析一下nash_main(int argc,char *a…

高效视频剪辑:视频批量调色,如何利用色调调整提升效率

在视频剪辑的后期处理中&#xff0c;调色是一个至关重要的环节。它不仅能够改变视频的整体氛围和风格&#xff0c;还能够突出视频的重点&#xff0c;增强观众的视觉体验。然而&#xff0c;对于大量的视频素材进行逐个调色处理&#xff0c;无疑会耗费大量的时间和精力。我们可以…

软件安装及YOLOv8环境配置及验证

先附上本章中所用到的软件及环境安装包&#xff0c;还有YOLOv8各任务权重&#xff1a; 软件及环境配置链接&#xff1a;https://pan.baidu.com/s/1-n2HJybicA6vW1YXfGRtcA 提取码&#xff1a;6vh8 YOLOv8各权重&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1ApYUrJ_s…

C++相关概念和易错语法(12)(迭代器、string容量调整)

1.迭代器&#xff08;以string为例&#xff09; &#xff08;1&#xff09;基本理解&#xff1a;在我们刚接触迭代器的时候&#xff0c;我们可以将迭代器理解为改造过的“指针”&#xff0c;这是一个新的类型&#xff0c;指向对应容器中的各个元素。我们可以像指针那样对迭代器…

Lombok介绍、使用方法和安装

目录 1 Lombok背景介绍 2 Lombok使用方法 2.1 Data 2.2 Getter/Setter 2.3 NonNull 2.4 Cleanup 2.5 EqualsAndHashCode 2.6 ToString 2.7 NoArgsConstructor, RequiredArgsConstructor and AllArgsConstructor 3 Lombok工作原理分析 4. Lombok的优缺点 5. 总结 1 …

Idea入门:一分钟创建一个Java工程

一&#xff0c;新建一个Java工程 1&#xff0c;启动Idea后&#xff0c;选择 [New Project] 2&#xff0c;完善工程信息 填写工程名称&#xff0c;根据实际用途取有意义的英文名称选择Java语言&#xff0c;可以看到还支持Kotlin、Javascript等语言选择包管理和项目构建工具Mav…

LVS的三种工作模式---(DR/TUN/NAT)

目录 一、NAT模式&#xff08;LVS-NAT&#xff09; 二、IP隧道模式&#xff08;LVS-TUN&#xff09; 三、DR模型--直接路由模式&#xff08;LVS-DR&#xff09; LVS/DR模式ARP抑制 原因&#xff1a; LVS的DR工作模式及配置&#xff1a; LVS的NAT工作模式及配置&#xff1…

PyQt6--Python桌面开发(7.QTextEdit多行富文本框控件)

QTextEdit多行富文本框控件 保存文件到本地QLine多行文本框.ui import sys import time from PyQt6.QtGui import QValidator,QIntValidator from PyQt6.QtWidgets import QApplication,QLabel,QLineEdit,QTextEdit from PyQt6 import uic,QtGuiif __name__ __main__:appQApp…

二叉树进阶 --- 上

目录 1. 二叉搜索树的概念及结构 1.1. 二叉搜索树的概念 1.2. 二叉搜索树的结构样例 2. 二叉搜索树的实现 2.1. insert 的非递归实现 2.2. find 的非递归实现 2.3. erase 的非递归实现 2.3.1. 第一种情况&#xff1a;所删除的节点的左孩子为空 2.3.1.1. 错误的代码 2…

基本QinQ

拓扑图 配置 开启LLDP功能&#xff0c;查看是否能通过QinQ隧道透传 sysname AR1 # lldp enable # interface GigabitEthernet0/0/0.10dot1q termination vid 10ip address 12.1.1.1 255.255.255.0 arp broadcast enable # sysname AR2 # lldp enable # interface GigabitE…

地磁暴红色预警来袭,普通人该如何应对?绝绝子的防护指南来了

近日&#xff0c;国家空间天气监测预警中心发布了一则令人瞩目的消息——地磁暴红色预警。这一预警不仅提醒我们地磁暴即将影响我国的电离层和低轨卫星&#xff0c;更让我们深刻认识到地球空间环境的脆弱性和复杂性。对于普通公众而言&#xff0c;地磁暴的概念可能相对陌生&…

【每日刷题】Day37

【每日刷题】Day37 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;每日刷题&#x1f34d; &#x1f33c;文章目录&#x1f33c; 1. 2391. 收集垃圾的最少总时间 - 力扣&#xff08;LeetCode&#xff09; 2. 1614. 括号的最大嵌套深度…

你可能喜欢但也许还不知道的好用网站-搜嗖工具箱

在线工具 https://www.zxgj.cn/ 作为一个工作生活好帮手&#xff0c;在线咨询网站提供了丰富的实用功能&#xff0c;从工作中的图表制作、图片修改到生活中的各种测试、健康、娱乐、学习、理财等等涵盖面很广。 在线工具网站从界面和操作上来看对用户也很友好&#xff0c;页面…

论文研读 An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale

完整翻译 《An Image is Worth 16x16 Words》完整版翻译_an image is worth 16*16words-CSDN博客 大神讲解 Vision Transformer详解-CSDN博客 视频讲解 11.1 Vision Transformer(vit)网络详解_哔哩哔哩_bilibili 学习整理 简要概述&#xff1a;Vision Transformer&#xff…

在 Kubernetes 上运行 Apache Spark 进行大规模数据处理的实践

在刚刚结束的 Kubernetes Community Day 上海站&#xff0c;亚马逊云科技在云原生分论坛分享的“在 Kunernets 上运行 Apache Spark 进行大规模数据处理实践”引起了现场参与者的关注。开发者告诉我们&#xff0c;为了充分利用 Kubernetes 的高可用设计、弹性&#xff0c;在越来…