メニュー グループ

メニュー グループは、関連するコマンドとコントロールをメニューまたはツール バー内に整理します。

はじめに

MenuGroup マークアップ要素を通じて公開されるメニュー グループ コントロールは、コンテキスト ポップアップ ミニ ツール バーを含むメニュー ベースのコントロール内の項目またはコマンドのグループの論理コンテナーです。

ラベルは、関連付けられた Command 宣言の LabelTitle 属性または Command.LabelTitle プロパティを使用して、メニュー グループに指定できます。 LabelTitle に割り当てられた値は、カテゴリ ヘッダーとしてレンダリングされます。

次の例では、2 つのメニュー グループ コマンド宣言を含む 分割ボタン コントロールの Command マークアップを示します。

<!-- SplitButton -->
<Command Name="cmdSplitButtonGroup"
         Symbol="cmdSplitButtonGroup"
         Comment="SplitButton Group"
         LabelTitle="SplitButton"/>
<Command Name="cmdSplitButton"
         Symbol="cmdSplitButton"
         Comment="SplitButton"
         LabelTitle="SplitButton"/>
<Command Name="cmdSBButtonItem"
         Symbol="cmdSBButtonItem"
         Comment="SBButtonItem"
         LabelTitle="SB ButtonItem"/>
<Command Name="cmdSBButton1"
         Symbol="cmdSBButton1"
         Comment="SBButton1"
         LabelTitle="SB Button">
  <Command.LargeImages>
    <Image Source="res/copyL_32.bmp"/>
  </Command.LargeImages>
  <Command.SmallImages>
    <Image Source="res/copyS_16.bmp"/>
  </Command.SmallImages>
  <Command.LargeHighContrastImages>
    <Image Source="res/copyLHC_32.bmp"/>
  </Command.LargeHighContrastImages>
  <Command.SmallHighContrastImages>
    <Image Source="res/copySHC_16.bmp"/>
  </Command.SmallHighContrastImages>
</Command>
<Command Name="cmdSBMajorItems"
         Comment="Major Items Category"
         LabelTitle="Major Items"/>
<Command Name="cmdSBStandardItems"
         Comment="Standard Items Category"
         LabelTitle="Standard Items"/>

次の例では、3 つの MenuGroup 要素宣言を持つ SplitButton 要素に必要なマークアップを示します。そのうちの 2 つが前の例の Menu Group Commands に関連付けられています。 MenuGroup 要素の Class 属性は、メニュー項目のサイズを指定するために使用されます。

<Group CommandName="cmdSplitButtonGroup">
  <SplitButton CommandName="cmdSplitButton">
    <SplitButton.ButtonItem>
      <Button CommandName="cmdSBButtonItem"/>
    </SplitButton.ButtonItem>
    <SplitButton.MenuGroups>
      <MenuGroup CommandName="cmdSBMajorItems" 
                 Class="MajorItems">
        <Button CommandName="cmdSBButton1"/>
        <Button CommandName="cmdSBButton1"/>
      </MenuGroup>
      <MenuGroup CommandName="cmdSBStandardItems"
                 Class="StandardItems">
        <Button CommandName="cmdSBButton1"/>
        <Button CommandName="cmdSBButton1"/>
      </MenuGroup>
      <MenuGroup Class="StandardItems">
        <Button CommandName="cmdSBButton1"/>
        <Button CommandName="cmdSBButton1"/>
      </MenuGroup>
    </SplitButton.MenuGroups>
  </SplitButton>
</Group>

次のスクリーン ショットは、前の例のマークアップから生成されたメニュー (3 つのメニュー グループ コントロールを含む) を示しています。

3 つのメニュー グループ コントロールを含むメニューのスクリーン ショット。

リボン フレームワークは、メニュー グループ コントロールの プロパティ キー のコレクションを定義します。

通常、メニュー グループ プロパティは、 IUIFramework::InvalidateUICommand メソッドの呼び出しによってコントロールに関連付けられている Command を無効にすることで、リボン UI で更新されます。 無効化イベントが処理され、 IUICommandHandler::UpdateProperty コールバック メソッドによって定義されたプロパティが更新されます。

IUICommandHandler::UpdateProperty コールバック メソッドは実行されず、アプリケーションは、フレームワークでプロパティが必要になるまで、更新されたプロパティ値を照会しました。 たとえば、タブがアクティブ化され、リボン UI にコントロールが表示されたときや、ツールヒントが表示されたときなどです。

注意

場合によっては、 IUIFramework::GetUICommandProperty メソッドを使用してプロパティを取得し、 IUIFramework::SetUICommandProperty メソッドを使用して設定できます。

 

次の表に、メニュー グループ コントロールに関連付けられているプロパティ キーの一覧を示します。

プロパティ キー メモ
UI_PKEY_Enabled IUIFramework::GetUICommandPropertyIUIFramework::SetUICommandProperty をサポートします。
UI_PKEY_Keytip 無効化によってのみ更新できます。
UI_PKEY_Label 無効化によってのみ更新できます。
UI_PKEY_TooltipDescription 無効化によってのみ更新できます。
UI_PKEY_TooltipTitle 無効化によってのみ更新できます。

 

Windows リボン フレームワーク コントロール ライブラリ

MenuGroup マークアップ要素