Access Ribbon Controls Programmatically in XML Ribbon

To program Office add-ins using C # 4.0, Microsoft provides two different ways to create and / or change the ribbon interface: you can use the Ribbon Designer or define the ribbon layout in the XML Ribbon .

If you create a ribbon using the Ribbon designer, the class generated in the code behind has visibility for all the controls that you placed on the ribbon. Therefore, if I placed RibbonDropDown under the name "dropdown1", I could use the following code to add an element to it:

RibbonDropDownItem item = Factory.CreateRibbonDropDownItem();
item.Label = submatrix.Name;
item.Tag = submatrix;
this.dropDown1.Items.Add(item);

However, if you create the same tape using Ribbon XML, dropDown1 or Factory will not be found ("The name does not exist in the current context").

Is there a way to access the elements added to the ribbon attached to the ribbon in the code?

+3
source share
1 answer

It may be a little late, but hopefully this helps someone.

. , , . , onAction, ,

ribbon.InvalidateControl("MyCtl");

MS Lab,

+4

All Articles