Search code examples
menugallerywindows-ribbon-framework

Windows ribbon framework: Galleries in the ApplicationMenu


According to MS documentation, the ribbon framework's application menu should be able to host DropDownGallery elements, but I can't get this past the uicc compiler. For example:

<Ribbon.ApplicationMenu>
  <ApplicationMenu CommandName="AppMenu" >
    <ApplicationMenu.RecentItems>
      <RecentItems CommandName="RecentItems" EnablePinning="false" MaxCount="15" />
    </ApplicationMenu.RecentItems>
    <MenuGroup Class="MajorItems">
      <DropDownGallery CommandName="MyAppGallery" Type="Commands" HasLargeItems="false">
        <DropDownGallery.MenuLayout>
          <VerticalMenuLayout Gripper="None"/>
        </DropDownGallery.MenuLayout>
      </DropDownGallery>
    </MenuGroup>
  </ApplicationMenu>
</Ribbon.ApplicationMenu>

This results in an SC1053 error from the uicc compiler:

error SC1053 : The attribute 'Type' on the element '{http://schemas.microsoft.com/windows/2009/Ribbon}DropDownGallery' is not defined in the DTD/Schema.

The same DropDownGallery syntax works everywhere else in our app, and the MS docs explicitly state that DropDownGallery is a permitted element in a MenuGroup.

What gives?


Solution

  • Answering my own question:

    It turns out that there are two issues here.

    1. Galleries in the app menu are limited. The only supported layout is a one-level vertical menu of commands, and the only supported attributes are CommandName and ApplicationMode. These limitations are not mentioned anywhere in the MS documentation.

    2. There is an apparent bug in the ribbon compiler, uicc.exe: It does not allow any whitespace anywhere in the element markup except between attributes.

    Putting these together, here is the only markup that really works for a gallery in the app menu:

    <DropDownGallery CommandName="MyAppGallery"/>
    

    or

    <DropDownGallery CommandName="MyAppGallery"></DropDownGallery>
    

    Note in particular that the only space is between the element name and the attribute. Even a space between the > and the </ will cause an error in the ribbon compiler:

    <!-- this will fail! -->
    <DropDownGallery CommandName="MyAppGallery"> </DropDownGallery>