WPF Ribbon 4.0 - 控制级别的尺寸定义 [英] WPF Ribbon 4.0 - Size definition at control level

查看:77
本文介绍了WPF Ribbon 4.0 - 控制级别的尺寸定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了这样的东西

I have defined something like this

<ribbon:RibbonGroup Header="Size at Control Level">
                    <ribbon:RibbonControlGroup>
                        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 1">
                            <ribbon:RibbonButton.ControlSizeDefinition>
                                <ribbon:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"></ribbon:RibbonControlSizeDefinition>
                            </ribbon:RibbonButton.ControlSizeDefinition>
                        </ribbon:RibbonButton>
                        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 2">
                            <ribbon:RibbonButton.ControlSizeDefinition>
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"></ribbon:RibbonControlSizeDefinition>
                            </ribbon:RibbonButton.ControlSizeDefinition>
                        </ribbon:RibbonButton>
                        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 3"></ribbon:RibbonButton>
                        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 4"></ribbon:RibbonButton>
                    </ribbon:RibbonControlGroup>
                </ribbon:RibbonGroup>

但是所有的按钮都很大.即使我为所有控件设置了一个带有 Small 的 ControlSizeDefinition 属性,它们仍然很大.我做错了什么?

But all the buttons are large. Even if I set a ControlSizeDefinition property with Small for all the controls, they still are large. What am I doing wrong?

谢谢!

推荐答案

来自 MSDN:Ribbon Layout and Resizing(大约页面一半的小文本):

From MSDN: Ribbon Layout and Resizing (about halfway down the page in small text):

控制组

相关的功能区控件可以组合在一个功能区控制组.当一个控制组被调整大小时,一个RibbonControlSizeDefinition 应用于功能区控制组.RibbonControlGroup 位于RibbonGroup 就像一个控件一样.

Related ribbon controls can be grouped together in a RibbonControlGroup. When a control group is resized, one RibbonControlSizeDefinition is applied to all of the controls in the RibbonControlGroup. The RibbonControlGroup is positioned in the RibbonGroup as if it were one control.

因此,如果多个 RibbonButton 位于一个公共 RibbonControlGroup(如您的示例所示)中,那么它们将始终共享相同的 RibbonControlSizeDefinition.在 WPF 功能区的当前状态下,您将无法指定不同的大小.您需要对它们进行不同的分组才能达到这种效果.(也许将它们放在包裹在边框内的堆栈面板中......但我担心将非功能区控件放在功能区上有时会破坏功能区的良好内置功能).

So if multiple RibbonButtons are in a common RibbonControlGroup (as your example shows) then they will always share the same RibbonControlSizeDefinition. In the current state of the WPF Ribbon, you will not be able to specify different sizes. You would need to group them differently to achieve such an effect. (maybe putting them in a stackpanel wrapped within a border... but I fear that putting non-ribbon controls onto the ribbon sometimes ruins the nice built in features of the ribbon).

我怀疑您真的不打算将所有四个按钮放在一个控制组中.RibbonControlGroup 旨在将非常密切相关的按钮粘合在一起",因此一个按钮结束和下一个按钮开始之间的间距为 0.这不适用于不同大小的按钮.我认为您可能只是希望您的按钮直接放在 Ribbon Group 中,因为这应该是告诉用户按钮以某种方式相关的容器.

I suspect you really don't intend to put all four of your buttons within a single control group. A RibbonControlGroup is intended to 'glue very closely related buttons together' so there is 0 spacing between where one button ends and the next begins. This doesn't work well for buttons of different size. I think you may just want your buttons to be placed directly in the Ribbon Group, as that should really be the container that tells a user that the buttons are related somehow.

附加说明:您可以在 RibbonControlGroup 上指定一个大小定义,该定义将应用于其中的所有四个按钮,如下所示:

An additional side note: You can specify a size definition on the RibbonControlGroup that will apply to all four of your buttons within it like so:

<ribbon:RibbonGroup Header="Size at Control Level">
    <ribbon:RibbonControlGroup>
        <ribbon:RibbonControlGroup.ControlSizeDefinition>
            <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False" />
        </ribbon:RibbonControlGroup.ControlSizeDefinition>
        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 1" />
        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 2" />
        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 3" />
        <ribbon:RibbonButton SmallImageSource="Images\wizard-icon16.png" LargeImageSource="Images\wizard-icon32.png" Label="Button 4" />
    </ribbon:RibbonControlGroup>
</ribbon:RibbonGroup>

这篇关于WPF Ribbon 4.0 - 控制级别的尺寸定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆