布局组时,Windows Ribbon Framework 支持 一些预定义的布局. 。其中一种布局,需要 按钮被称为 FourButtons.

此布局支持 3 种不同的尺寸, 大的, 中等的, , 和 小的. 。在每种情况下,它都会给出布局:

大的:

enter image description here

中等的:

enter image description here

小的:

enter image description here

现在我正在使用 FourButtons 我的 xml 文件中的预定义模板为:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/windows/2009/Ribbon">
   ...
   <Application.Views>
      <Ribbon>
         ...
         <Ribbon.Tabs>
            <Tab CommandName="tabHome">
               <Group CommandName="grpActivity" SizeDefinition="FourButtons">
                  <Button CommandName="cmdStartWorking" />
                  <Button CommandName="cmdStopWorking" />
                  <Button CommandName="cmdPrint" />
                  <Button CommandName="cmdDuplicateTicket" />
               </Group>
            </Tab>
         </Ribbon.Tabs>

      </Ribbon>
   </Application.Views>
</Application>

你可以看到这条线

<Group CommandName="grpActivity" SizeDefinition="FourButtons">

其中指定了 FourButtons 布局模板。

我的布局是 四按钮:

alt text

除非我不想 四按钮 布局,我想要“四个按钮,两大两小".

以同样的方式,有 ThreeButtons-OneBigAndTwoSmall:

enter image description here

并且有一个 FiveButtons:

enter image description here

我想要一个 FourButtons-TwoBigTwoSmall, ,我可以手动模拟:

alt text

不幸的是声明式编程 微软为创建自定义布局而发明的 让我作为一个程序员感到困惑。

任何人都可以破译页面底部的声明性语言示例并提出一个 四按钮-二大二小 模板?

笔记: 所有漂亮的图形、格式、链接和东西都是用来吸引松鼠的——它们喜欢闪亮的图形。如果你真的读到这里我可以 实际上 使用你的帮助。

有帮助吗?

解决方案

应使用 BigButtonsAndSmallButtonsOrInputs SizeDefinition

e.g。

      <Group CommandName="cmdGroupBatch" SizeDefinition="BigButtonsAndSmallButtonsOrInputs">
        <ControlGroup>
          <Button CommandName="cmdButtonGetBatch" />
          <Button CommandName="cmdButtonPutBatch" />
        </ControlGroup>
        <ControlGroup>
          <Button CommandName="cmdButtonSaveBatch" />
          <Button CommandName="cmdButtonDiscartBatch" />
        </ControlGroup>
      </Group>

只是检查,如果您的集团拥有大小= “大” 在你的Tab.ScalingPolicy。

其他提示

我最终确实弄清楚了。

首先是控制图,它要求该组有(在本例中)四个按钮。通过在中有四个条目 ControlNameMap 我们要求使用此尺寸定义的组实际上有四个按钮。

<ControlNameMap>
   <ControlNameDefinition Name="button1"/>
   <ControlNameDefinition Name="button2"/>
   <ControlNameDefinition Name="button3"/>
   <ControlNameDefinition Name="button4"/>
</ControlNameMap>

这四个按钮都有别名:

  • button1
  • button2
  • button3
  • button4

以便可以在下面的定义中引用它们。首先是 大的 模板:

<GroupSizeDefinition Size="Large">
    <ControlSizeDefinition ControlName="button1" ImageSize="Large" IsLabelVisible="true" />
    <ControlSizeDefinition ControlName="button2" ImageSize="Large" IsLabelVisible="true" />
    <ColumnBreak ShowSeparator="true"/>
    <ControlSizeDefinition ControlName="button3" ImageSize="Large" IsLabelVisible="true" />
    <ControlSizeDefinition ControlName="button4" ImageSize="Large" IsLabelVisible="true" />
</GroupSizeDefinition>

这会导致两个大按钮、一个分隔符和另外 2 个大按钮。

中等的 模板:

<GroupSizeDefinition Size="Medium">
    <ControlSizeDefinition ControlName="button1" ImageSize="Large" IsLabelVisible="true" />
    <ControlSizeDefinition ControlName="button2" ImageSize="Large" IsLabelVisible="true" />
    <ColumnBreak ShowSeparator="true"/>
    <Row>
        <ControlSizeDefinition ControlName="button3" ImageSize="Small" IsLabelVisible="true" />
    </Row>
    <Row>
        <ControlSizeDefinition ControlName="button4" ImageSize="Small" IsLabelVisible="true" />
    </Row>
</GroupSizeDefinition>

导致两个大按钮、一个分隔符,然后是两行(每行包含一个小按钮)。

小的 模板:

<GroupSizeDefinition Size="Small">
    <Row>
        <ControlSizeDefinition ControlName="button1" ImageSize="Small" IsLabelVisible="true" />
        <ControlSizeDefinition ControlName="button3" ImageSize="Small" IsLabelVisible="false" />
    </Row>
    <Row>
        <ControlSizeDefinition ControlName="button2" ImageSize="Small" IsLabelVisible="true" />
        <ControlSizeDefinition ControlName="button4" ImageSize="Small" IsLabelVisible="false" />
    </Row>
</GroupSizeDefinition>

导致出现两行,每行有两个小按钮。


把它们放在一起:

<Group CommandName="grpActivity" >
    <SizeDefinition>
        <ControlNameMap>
            <ControlNameDefinition Name="button1"/>
            <ControlNameDefinition Name="button2"/>
            <ControlNameDefinition Name="button3"/>
            <ControlNameDefinition Name="button4"/>
        </ControlNameMap>
        <GroupSizeDefinition Size="Large">
            <ControlSizeDefinition ControlName="button1" ImageSize="Large" IsLabelVisible="true" />
            <ControlSizeDefinition ControlName="button2" ImageSize="Large" IsLabelVisible="true" />
            <ColumnBreak ShowSeparator="true"/>
            <ControlSizeDefinition ControlName="button3" ImageSize="Large" IsLabelVisible="true" />
            <ControlSizeDefinition ControlName="button4" ImageSize="Large" IsLabelVisible="true" />
        </GroupSizeDefinition>
        <GroupSizeDefinition Size="Medium">
            <ControlSizeDefinition ControlName="button1" ImageSize="Large" IsLabelVisible="true" />
            <ControlSizeDefinition ControlName="button2" ImageSize="Large" IsLabelVisible="true" />
            <ColumnBreak ShowSeparator="true"/>
            <Row>
                <ControlSizeDefinition ControlName="button3" ImageSize="Small" IsLabelVisible="true" />
            </Row>
            <Row>
                <ControlSizeDefinition ControlName="button4" ImageSize="Small" IsLabelVisible="true" />
            </Row>
        </GroupSizeDefinition>
        <GroupSizeDefinition Size="Small">
            <Row>
                <ControlSizeDefinition ControlName="button1" ImageSize="Small" IsLabelVisible="true" />
                <ControlSizeDefinition ControlName="button3" ImageSize="Small" IsLabelVisible="false" />
            </Row>
            <Row>
                <ControlSizeDefinition ControlName="button2" ImageSize="Small" IsLabelVisible="true" />
                <ControlSizeDefinition ControlName="button4" ImageSize="Small" IsLabelVisible="false" />
            </Row>
        </GroupSizeDefinition>
    </SizeDefinition>

    <Button CommandName="cmdStartWorking" />
    <Button CommandName="cmdStopWorking" />
    <Button CommandName="cmdPrint" />
    <Button CommandName="cmdDuplicateTicket" />
</Group>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top