Windows 7 リボン:「4 つのボタン、大 2 つ、小 2 つ」を指定するにはどうすればよいですか?
-
25-09-2019 - |
質問
グループをレイアウトするとき、Windows リボン フレームワークはサポートします。 いくつかの事前定義されたレイアウト. 。必要なレイアウトの 1 つ 四 ボタンが呼び出されます FourButtons
.
このレイアウトは 3 つの異なるサイズをサポートしています。 大きい, 中くらい, 、 そして 小さい. 。それぞれの場合において、レイアウトは次のようになります。
大きい:
中くらい:
小さい:
今私が使っているのは、 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
レイアウトテンプレート。
そして私のレイアウトは 4 つのボタン:
私が望んでいないことを除いて 4 つのボタン レイアウト、欲しいです」4 つのボタン、大 2 つ、小 2 つ".
あるのと同じように ThreeButtons-OneBigAndTwoSmall
:
そして、 FiveButtons
:
が欲しい FourButtons-TwoBigTwoSmall
, 、手動でモックアップできます。
残念ながら宣言型プログラミング Microsoft がカスタム レイアウトを作成するために発明したもの プログラマーとして私を困惑させます。
ページの下部にある宣言型言語の例を解読して、次のことを思いつく人はいますか? 4 つのボタン 2 つ大きな 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に= "大" サイズを持っている場合。
他のヒント
私は最終的にそれを理解しました。
1 つ目は、グループに (この場合) 4 つのボタンがあることを義務付けるコントロール マップです。に 4 つのエントリがあることで、 ControlNameMap
このサイズ定義を使用するグループには実際に 4 つのボタンがあることが義務付けられます。
<ControlNameMap>
<ControlNameDefinition Name="button1"/>
<ControlNameDefinition Name="button2"/>
<ControlNameDefinition Name="button3"/>
<ControlNameDefinition Name="button4"/>
</ControlNameMap>
4 つのボタンには次のエイリアスが与えられます。
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 つの大きなボタン、セパレータ、および別の 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>
2 つの大きなボタン、1 つのセパレータ、そして 2 つの行 (各行には 1 つの小さなボタンが含まれます) が表示されます。
の 小さい テンプレート:
<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>
2 行に 2 つの小さなボタンが表示されます。
すべてをまとめると:
<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>