wpf 如何向 DevExpress RibbonControl 添加按钮?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17675260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:13:32  来源:igfitidea点击:

How to add buttons to DevExpress RibbonControl?

c#wpfdevexpressribbon-control

提问by Dua Ali

I am using DevExpress WPF MVVM Framework. I want to add buttons above the "Home" tab as shown by this image. How is it possible? enter image description here

我正在使用 DevExpress WPF MVVM 框架。我想在“主页”选项卡上方添加按钮,如图所示。这怎么可能?在此处输入图片说明

<dxb:BarManager> 
    <dxb:BarManager.Items>
        <dxb:BarButtonItem x:Name="barButtonItem1" Content="About" Glyph="pack://application:,,,/DevExpress.Images.v13.1;component/Images/Support/Info_16x16.png" LargeGlyph="pack://application:,,,/DevExpress.Images.v13.1;component/Images/Support/Info_32x32.png" Command="{Binding ShowAboutCommand}"/>
        <dxb:BarButtonItem x:Name="barButtonItem2" Content="New" />
        <dxb:BarButtonItem x:Name="SaveCommandBarButtonItem" Content="Save" />
    </dxb:BarManager.Items>
...               

回答by Tameen Malik

Dua, Please visit this link http://www.devexpress.com/Support/Center/Question/Details/Q510019, same question has posted there. May be it will help you.

Dua,请访问此链接http://www.devexpress.com/Support/Center/Question/Details/Q510019,同样的问题已发布在那里。也许它会帮助你。

Devexpress FAQ provides facility to ask Questions, Devexpress support team can better answer to solve queries related to their tools. Thanks, Tameen

Devexpress FAQ 提供了提问的工具,Devexpress 支持团队可以更好地回答与他们的工具相关的问题。谢谢,塔米恩

回答by J.Hudler

What you're willing to do is not add a button, but a page.

您愿意做的不是添加按钮,而是添加页面

Take a look in this link below:

看看下面这个链接:

http://documentation.devexpress.com/#wpf/CustomDocument7954

http://documentation.devexpress.com/#wpf/CustomDocument7954



EDIT due to comment

由于评论而编辑

That "area" you want to add buttons is called Page Headerin a Ribbon.

您要添加按钮的“区域”称为功能区中的页眉

This link below shows how to but them there:

下面的链接显示了如何将它们放在那里:

http://documentation.devexpress.com/#wpf/CustomDocument8186

http://documentation.devexpress.com/#wpf/CustomDocument8186

I'm not sure about what sizing / positioning capabilities you will have though (considering the exact layout you intended in your image).

我不确定您将拥有什么尺寸/定位功能(考虑到您在图像中想要的确切布局)。

回答by DmitryG

You can't add a buttons in any place of RibbonControl because the RibbonControl is not intended to be used in this way. You should use ribbon item links(buttons, sub-menus, in-place editors, galleries, etc.) combined into groupsand pages. Please review the RibbonControl Conceptsarticle for more information.
Related example: How to create a Ribbon Control

您不能在 RibbonControl 的任何位置添加按钮,因为 RibbonControl 不打算以这种方式使用。您应该使用组合成页面的功能区项目链接(按钮、子菜单、就地编辑器、画廊等)。请查看RibbonControl 概念文章以获取更多信息。 相关示例:如何创建功能区控件

If you want to add items on the right edge of the RibbonControl (Page Header Region) you can use approach described in How to add commands to the Page Header Regionarticle.

如果您想在 RibbonControl(页眉区域)的右边缘添加项目,您可以使用如何将命令添加到页眉区域一文中描述的方法。

If you want to add items to the top edge of RibbonControl (Quick Access Toolbar) you can use approach described in How to add items to the Quick Access Toolbararticle.

如果要将项目添加到 RibbonControl(快速访问工具栏)的顶部边缘,您可以使用如何将项目添加到快速访问工具栏一文中描述的方法。

P.S. I see you are using the MVVM Framework. Thus you should also review the following article: MVVM Framework Getting Started (Lesson 2) - Customize a Ribbon and Create an About Button

PS 我看到您正在使用 MVVM 框架。因此,您还应该查看以下文章:MVVM 框架入门(第 2 课)- 自定义功能区并创建关于按钮