getSelectedItemIndex/getSelectedItemID callback on Gallery in ribbon throws custom UI error when nothing selected RRS feed

  • Question

  • I have defined some ribbon XML for a number of items to be shown in a gallery. Initially, I don't want any of the items to be selected, but when 'Show Add-in User Interface Errors' is enabled in the Office application I get a custom UI error on startup: "The callback function 'GetSelectedItemIdCallback' on control 'myGallery' returned an invalid value"

    A simplified version of the ribbon xml is:

     <group id="myGroup" label="Test">
       <gallery id="myGallery" label="Test" size="large" rows="2" columns="2" showItemImage="true" onAction="OnActionCallback" getSelectedItemID="GetSelectedItemIdCallback"  >
      <item id="item1" label="R1 C1" imageMso="HappyFace" />
      <item id="item2" label="R1 C2" imageMso="ColorRed" />
      <item id="item3" label="R2 C2" imageMso="ColorYellow" />
      <item id="item4" label="R3 C1" imageMso="ColorLime" />

    and the code for the callbacks is:

            string _selectedItemID = null;
            public void OnActionCallback(Office.IRibbonControl ribbonControl, string selectedId, int selectedIndex)
                _selectedItemID = selectedId;
            public string GetSelectedItemIdCallback(Office.IRibbonControl ribbonControl)
                return _selectedItemID;

    I've tried returning null and an empty string for the callback when I don't want anything to be selected, but I still get the error. I've also tried using the 'getSelectedItemIndex' callback and returning -1 but that still causes a custom UI error

    Does anyone know if I am missing something here?



    • Edited by Steve D. _ Monday, May 20, 2019 9:38 AM
    Monday, May 20, 2019 9:25 AM

All replies