none
How to dynamically add buttons to split button's menu through Ribbon xml? RRS feed

  • Question

  • We need the result like this, and we don't want to accomplish this through  getvisible control.

    If we use add dynamic menu to split button's menu, the result will be quite different.Anyone has idea?


    • Edited by 董建华 Thursday, March 6, 2014 6:21 AM
    Thursday, March 6, 2014 3:20 AM

Answers

  • The article you point to says that the solution requires the getLabel and getVisible callbacks. There is no other way to accomplish this - the Ribbon design does not allow for it. With the exception of dynamic menus, gallery lists and dropdown lists all items in a Ribbon MUST be defined at Design time in the Ribbon XML.

    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by 董建华 Thursday, March 6, 2014 8:14 AM
    Thursday, March 6, 2014 7:04 AM
    Moderator

All replies

  • I want to know how to add menu item dynamic to SplitButton through ribbon xml。
    Tuesday, March 4, 2014 8:24 AM
  • Hello,

    You need to specify the getContent attribute for the dynamicMenu control and add the following callback in the code behind file:

    C#: string GetContent(IRibbonControl control)

    VBA: Sub GetContent(control As IRibbonControl, ByRef content)

    C++: HRESULT GetContent([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrContent)

    Visual Basic: Function GetContent(control As IRibbonControl) As String

    In the code of your callback you can create the XML markup with controls you want to display at runtime dynamically.

    The Adding Custom Dynamic Menus to the Office Fluent User Interface describes all the required steps in depth.

    • Proposed as answer by Marvin_Guo Wednesday, March 5, 2014 8:35 AM
    • Unproposed as answer by 董建华 Thursday, March 6, 2014 6:18 AM
    Tuesday, March 4, 2014 8:56 AM
  • Could you please give me a sample colde example?
    Tuesday, March 4, 2014 8:59 AM
  • The article provides the step-by-step guide for developing a dynamic menu. Did you try to go through the steps described?
    Tuesday, March 4, 2014 9:22 AM
  • I will look the article right now。 And i will choose your answer if it can resolve my issue。
    Tuesday, March 4, 2014 9:26 AM
  • do you have skype or other contact infromation?
    Tuesday, March 4, 2014 9:30 AM
  • if you add dynamic menu under splitbutton's menu, the result is not what we want.

    We want the result as the picture below.

    We want dynmic add button to split button's menu.


    • Edited by 董建华 Thursday, March 6, 2014 3:14 AM
    Thursday, March 6, 2014 3:13 AM
  • We need the result like this, and we don't want to accomplish this through  getvisible control

    If we use add dynamic menu to split button's menu, the result will be quite different.Anyone has idea?

    We need to accomplish the things like this article. 

    article link

    • Edited by 董建华 Thursday, March 6, 2014 6:44 AM
    Thursday, March 6, 2014 3:23 AM
  • The article you point to says that the solution requires the getLabel and getVisible callbacks. There is no other way to accomplish this - the Ribbon design does not allow for it. With the exception of dynamic menus, gallery lists and dropdown lists all items in a Ribbon MUST be defined at Design time in the Ribbon XML.

    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by 董建华 Thursday, March 6, 2014 8:14 AM
    Thursday, March 6, 2014 7:04 AM
    Moderator