代码之家  ›  专栏  ›  技术社区  ›  Ian Boyd

Windows7功能区:如何指定“四个按钮,两个大,两个小”?

  •  3
  • Ian Boyd  · 技术社区  · 14 年前

    在布局组时,Windows功能区框架支持一些预定义的布局。其中一个布局需要 四个按钮,称为 four buttons

    此布局支持3种不同的尺寸, large、 medium和 small。在每种情况下,它都给出了布局:

    medium :。

    small :。

    现在,我正在使用XML文件中的 fourbuttons predefined template as:。

    <?xml version=“1.0”encoding=“utf-8”?gt;
    <application xmlns=“http://schemas.microsoft.com/windows/2009/bribbon”>
    …
    <application.views>
    丝带& gt;
    …
    <Ribbon.Tabs>
    <tab commandname=“tabHome”>
    <group commandname=“grpactivity”sizedefinion=“fourbuttons”>
    <button commandname=“CmdStartWorking”/>
    <button commandname=“CmdStopWorking”/>
    <button commandname=“cmdprint”/>
    <button commandname=“CmdDuplicateTicket”/>
    及/组& GT;
    &标签;
    </Ribbon.Tabs>
    
    &丝带& gt;
    </application.views>
    </application>
    < /代码> 
    
    

    你可以看到这条线

    <group commandname=“grpactivity”sizedefinition=“fourbuttons”>
    < /代码> 
    
    

    它指定了fourbuttonslayout template。

    我的布局是fourbuttons:。

    alt文本http://i37.tinypic.com/15oupgk.jpg

    除了我不想要four buttonslayout,我想要“four buttons,two big two small”。

    以同样的方式,存在threebuttons onebigandtowoslill:。

    还有一个fivebuttons:。

    我想要一个fourbuttons twoBigtwoSmall,我可以手动模拟:

    alt文本http://i38.tinypic.com/30uy9ah.jpg

    不幸的是,声明性编程Microsoft发明用于创建自定义布局使我困惑为程序员。

    任何人都能破译页面底部的声明性语言示例并想出一个fourbutton twobigtwoosmalltemplate吗?

    注:所有漂亮的图形、格式、链接和东西都被用来吸引松鼠-谁喜欢闪亮的图形。如果你真的读到这里,我可以用你的帮助. 其中一个布局,需要按钮被调用FourButtons.

    此布局支持3种不同的大小,大的,培养基小的. 在每种情况下,它都给出了布局:

    大的:

    enter image description here

    培养基:

    enter image description here

    小的:

    enter image description here

    现在我正在使用四按钮我的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">
    

    它指定了四按钮布局模板。

    我的布局是四按钮:

    alt text http://i37.tinypic.com/15oupgk.jpg

    但我不想四按钮布局,我想要“四个按钮,两个大的两个小的“。

    和现在一样ThreeButtons-OneBigAndTwoSmall:

    enter image description here

    还有一个FiveButtons:

    enter image description here

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

    alt text http://i38.tinypic.com/30uy9ah.jpg

    不幸的是,声明性编程that Microsoft invented for creating custom layouts把我当成程序员搞糊涂了。

    任何人都能破译页面底部的声明性语言示例并想出一个四按钮双箭头模板?

    注:所有漂亮的图形、格式、链接和东西都被用来吸引那些喜欢闪亮图形的松鼠。如果你真的读到这么远,我可以事实上使用你的帮助。

    2 回复  |  直到 13 年前
        1
  •  2
  •   baCZa    14 年前

    你应该使用 大按钮和小按钮或输入 尺寸定义

    例如

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

    只要检查一下,如果您的团队在您的tab.scalingpolicy中有size=“large”。

        2
  •  1
  •   Ian Boyd    14 年前

    我终于弄明白了。

    首先是控制图,它要求组具有(在本例中)四个按钮。通过在 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>
    

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

    这个 中等的 模板:

    <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>