次の方法で共有


メニュー グループ

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

紹介

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

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

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

<!-- 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 つが前の例のメニュー グループ コマンドに関連付けられています。 メニュー項目のサイズを指定するには、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 メソッドの呼び出しによってコントロールに関連付けられているコマンドを無効にすることで、リボン UI で更新されます。 無効化イベントが処理され、IUICommandHandler::UpdateProperty コールバック メソッドによってプロパティが更新されます。

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

手記

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

 

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

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

 

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

MenuGroup マークアップ要素する