Dynamically adding RibbonButtons to Word Addin throws Collection is read-only

I am new to Word AddIns and trying to add Ribbon Group (s). for each RibbonGroup I dynamically add RibbonMenu and then add RibbonButtons to the menu within the group.

I got a rough job and it seems like it's ok, but whenever I access any collection

for example: group1.Items.add (new RibbonButton ()); it throws me to say that Collection is ReadOnly.

But when I debugged the Collection IsReadOnly checkbox, set to False, which clearly states that Collection is not readonly?

What am I missing.

+3
source share
2 answers

RibbonMenu RibbonGroup? , , , , [ , group1 - , !].

RibbonMenu, RibbonGroup , .
Items RibbonGroup:

// Summary:
//     Gets the controls in the group.
//
// Returns:
//     The collection of controls in the group.
//
// Exceptions:
//   System.InvalidOperationException:
//     You try to add, remove, or replace a Microsoft.Office.Tools.Ribbon.RibbonControl
//     after the Ribbon is loaded.
IList<RibbonControl> Items { get; }

, , IsReadOnly false.
RibbonGroup , .

. RibbonMenu , True RibbonMenu ( ), .

+2

All Articles