1、首先需要 下载Ribbon For WPF.目前最新的版本是Microsoft Ribbon for WPF October 2010。

下载 链接:

https://www.microsoft.com/en-us/download/details.aspx?id=11877#filelist

下载 完成后安装。

2、打开Visual Studio 2013创建WPF应用程序。添加程序集引用

"C:\Program Files (x86)\Microsoft Ribbon for WPF\V4.0\RibbonControlsLibrary.dll"

添加完成 后,将控件 程序集映射到XAML前缀

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

再在XAML中添加功能区控件

<r:Ribbon></r:Ribbon>

在添加内容前,我们需要先了解下RibbonWindow的结构:如图

①快速访问工具栏(QuickAccessToolBar)

①快速访问工具栏(QuickAccessToolBar)

<r:Ribbon.QuickAccessToolBar>
<r:RibbonQuickAccessToolBar>
<r:RibbonButton SmallImageSource="/Images/Save.png" LargeImageSource="/Images/Save.png"
ToolTipTitle="保存" ToolTipDescription="已其他形式保存该邮件" Command="SaveAs"/>
<r:RibbonButton SmallImageSource="/Images/Undo.png" LargeImageSource="/Images/Undo.png"
ToolTipTitle="撤销" ToolTipDescription="已其他形式保存该邮件" Command="ApplicationCommands.Undo" />
<r:RibbonButton SmallImageSource="/Images/Redo.png" LargeImageSource="/Images/Redo.png"
ToolTipTitle="恢复" ToolTipDescription="已其他形式保存该邮件" Command="ApplicationCommands.Redo"/>
<r:RibbonButton SmallImageSource="/Images/attach.png" LargeImageSource="/Images/attach.png"
ToolTipTitle="附件" ToolTipDescription="已其他形式保存该邮件" x:Name="quickAttachBtn" />
</r:RibbonQuickAccessToolBar>
</r:Ribbon.QuickAccessToolBar>

这个是在窗口icon旁边的快速访问工具栏,主要是给一些比较常用的按钮使用的。

②应用程序菜单(ApplicationMenu)

<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Images/ApplicationMenuIcon.png"
KeyTip="F">
<ribbon:RibbonApplicationMenuItem Header="Open"
Command="Open"
ImageSource="Images/Open32.png"
KeyTip="O" />
<ribbon:RibbonApplicationMenuItem Header="Save"
Command="Save"
ImageSource="Images/Save32.png"
KeyTip="S" />
<ribbon:RibbonApplicationSplitMenuItem Header="Save As"
Command="SaveAs"
ImageSource="Images/SaveAs32.png"
KeyTip="V" >
<ribbon:RibbonApplicationMenuItem Header="Rich Text document"
Command="SaveAs" CommandParameter="rtf"
ImageSource="Images/SaveAsRtf32.png"
KeyTip="R" />
<ribbon:RibbonApplicationMenuItem Header="Plain Text document"
Command="SaveAs" CommandParameter="txt"
ImageSource="Images/SaveAsTxt32.png"
KeyTip="P" />
<ribbon:RibbonApplicationMenuItem Header="Other format"
Command="SaveAs"
ImageSource="Images/SaveAs32.png"
KeyTip="O" />
</ribbon:RibbonApplicationSplitMenuItem>
<ribbon:RibbonSeparator />
<ribbon:RibbonApplicationSplitMenuItem Header="Print"
ImageSource="Images/Print32.png"
KeyTip="R" />
<ribbon:RibbonApplicationMenuItem Header="Page Setup"
ImageSource="Images/PrintSetup32.png"
KeyTip="G" />
<ribbon:RibbonApplicationMenu.FooterPaneContent>
<DockPanel LastChildFill="False">
<ribbon:RibbonButton Command="ApplicationCommands.Close"
Label="Exit"
ToolTipTitle="Exit"
SmallImageSource="Images\Exit16.png"
KeyTip="X"
DockPanel.Dock="Right"
Margin=""
BorderBrush="#B8114EAF" />
</DockPanel>
</ribbon:RibbonApplicationMenu.FooterPaneContent>
<ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
<ribbon:RibbonGallery CanUserFilter="False"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<ribbon:RibbonGalleryCategory Header="Recent Documents"
Background="Transparent"
ItemsSource="{DynamicResource MostRecentFiles}">
<ribbon:RibbonGalleryCategory.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" IsItemsHost="True"/>
</ItemsPanelTemplate>
</ribbon:RibbonGalleryCategory.ItemsPanel>
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>

③选项卡(RibbonTab)和组(RibbonGroup)

<r:RibbonTab x:Name="HomeTab"
Header="Home">
<r:RibbonGroup x:Name="Group1"
Header="Group1">
<r:RibbonGroup.GroupSizeDefinitions> <r:RibbonGroupSizeDefinition> <r:RibbonControlSizeDefinition ImageSize="Large" /> <r:RibbonControlSizeDefinition ImageSize="Small" /> <r:RibbonControlSizeDefinition ImageSize="Small" /> </r:RibbonGroupSizeDefinition> </r:RibbonGroup.GroupSizeDefinitions>
<r:RibbonButton x:Name="Button3" LargeImageSource="Images\LargeIcon.png" Label="Button1" /> <r:RibbonButton x:Name="Button1"
SmallImageSource="Images\SmallIcon.png"
Label="Button3" />
<r:RibbonButton x:Name="Button2"
SmallImageSource="Images\SmallIcon.png"
Label="Button4" />
</r:RibbonGroup>
<r:RibbonGroup>
<r:RibbonButton x:Name="Button5"
LargeImageSource="Images\LargeIcon.png"
Label="Button1" Click="Button5_Click" />
<r:RibbonButton x:Name="Button6"
SmallImageSource="Images\SmallIcon.png"
Label="Button2" /> </r:RibbonGroup>
</r:RibbonTab>

要让Group符合我们的想法,先要使用GroupSizeDefinitions对Group内的布局进行设置(当然不设置也是可以的,不过当我们讲到后面的让Ribbon随着应用的大小自动调整的时候就要使用到GroupSizeDefinitions了),使用ImageSize指定对应位置控件的大小,使用IsLabelVisible对控件的Lable是否可见进行设置。

Visual Studio 2013中使用Ribbon For WPF的更多相关文章

  1. 如何在Visual Studio 2013中使用Ribbon For WPF

    1.首先需要 下载Ribbon For WPF.目前最新的版本是Microsoft Ribbon for WPF October 2010. 下载 链接: https://www.microsoft. ...

  2. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(0):专题导航 [持续更新中]

    写在前面的话 随着 Visual Studio 2013 的正式推出,ASP.NET 和 Visual Studio Web 开发工具 也发布了各自的最新版本. 新版本在构建 One ASP.NET ...

  3. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(1):概述 - 创建 Web 应用程序项目

    注:本文是“在 Visual Studio 2013 中创建 ASP.NET Web 项目”专题的一部分,详情参见 专题导航 . 预备知识 本专题适用于 Visual Studio 2013 及以上版 ...

  4. 在 Visual Studio 2013 中使用 Grunt, Bower 和 NPM

    在 Visual Studio 2015 中提供了对于 Grunt 和 Gulp 的内置支持,在 Visual Studio 2013 中怎么办呢?微软将 2015 中的特性作为几个独立的扩展发布出来 ...

  5. 转载:在Visual Studio 2013中管理中国特色的社会主义Windows Azure

    原文链接: http://www.pstips.net/get-azurechinacloud-settings.html 谷歌被豪迈地放弃了中国市场,微软仍旧在中国市场摸爬滚打,跪着挣钱.其中私人定 ...

  6. 在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移

    在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移 最近发布的ASP.NET MVC 5 及Visual ...

  7. 在Visual Studio 2013 中使用C++单元测试

    本文主要介绍在Visual Studio 2013中对代码进行单元测试的方法,包含了两方面的内容:对已有的Dll文件进行单元测试,以及对已有的源文件进行单元测试. 1. VS2013对DLL文件的单元 ...

  8. 在Visual Studio 2013中修改远程Git服务器的地址

    在Visual Studio 2013中克隆了远程Git服务器的代码后,可以通过下图的方式修改Git服务器的地址:

  9. Visual Studio 2013中因SignalR的Browser Link引起的Javascript错误一则

    众所周知Visual Studio 2013中有一个由SignalR机制实现的Browser Link功能,意思是开发人员可以同时使用多个浏览器进行调试,当按下IDE中的Browser Link按钮后 ...

随机推荐

  1. MongoDB入门---文档查询操作之条件查询&and查询&or查询

    经过前几天的学习之路,今天终于到了重头戏了.那就是文档查询操作.话不多说哈,直接看下语法: db.collection.find(query, projection) query :可选,使用查询操作 ...

  2. linux signal函数遇到的问题

    1.关于signal函数的定义 signal最开始的原型是这: void (*signal(int signo, void (*func)(int)))(int);看过下面两行,了解到上面这一行是这个 ...

  3. WPF的退出

    很多时候,会自己写退出程序的代码. 比如,先显示登录框(LogIn),成功后隐藏它,并显示一个主窗体(MainWin),或者外部还调用了其他App,当你关闭MainWin不一定会直接退出整个程序的. ...

  4. 优步UBER司机全国各地奖励政策汇总 (2月15日-2月21日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  5. 封装一个Automapper单例

    public class DataModule : IModule { public void Configure(IMapperConfigurationExpression cfg) { //cf ...

  6. 【vps搬家】--总结--费元星

    20150310  费元星 稍微玩VPS/服务器比较久的站长手中应该不止一台VPS,我们会有多台机器之间的相互使用.比如可能会遇到的是数据传输,我们传统的做法是先用FTP下载数据A到本地,然后再到本地 ...

  7. android 学习六 构建用户界面和使用控件

    1.常用Android控件最终都会继承自View类 2.ViewGroup是一些布局类列表的基类,包括View和ViewGroup 3.构造界面的三种方法    a.完全使用代码(太灵活,而不好维护) ...

  8. nodejs学习笔记(2)

    1.express超时设置 如果http请求在一段时间内没有返回值,express会重新向后台发送请求.在后台方法执行时间较长的情况下,重复的请求会重复执行,造成前台接收到空的response,出现E ...

  9. Linux命令应用大词典-第17章 软件包管理

    17.1 rpm:RPM软件包管理器 17.2 rpmargs:处理RPM软件包 17.3 rpmbuild:构建RPM软件包 17.4 rpmdiff:比较两个软件包之间的不同 17.5 rpmel ...

  10. 使用InstallShield-Limited-Edition制作安装包

    1.打开此网站,进行注册,获取序列码以及下载InstallShield-Limited-Edition 2.安装完成之后,打开VisualStudio,新建项目 3.填写基本应用信息 4.配置相关信息 ...