3

布局组时,Windows功能区框架支持some predefined layouts。其中一个布局需要四个按钮称为FourButtonsWindows 7功能区:如何指定“四个按钮,两个大,两个小”?

此布局支持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布局模板。

而且我的布局是FourButtons

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

除了我不想FourButtons布局,我想 “四个按键,两个大两小”。

以同样的方式,有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让我为程序员困惑。

任何人都可以解释页面底部的声明性语言示例,并拿出一个FourButton-TwoBigTwoSmall template?

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

回答

2

你应该使用BigButtonsAndSmallButtonsOrInputs SizeDefinition

例如

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

+0

其实我有最终想通了。这绝对不是一件容易的事。但我会给你一个几乎同样好的解决方案。也因为你是唯一一个在41个视图中回应的人。 – 2010-11-19 19:45:48

1

我终于弄明白了。

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