Search code examples
c#wpfwpf-controlsribbonribbon-control

How to programmatically add a RibbonTab to WPF Ribbon (October 2010 release)?


Does anybody know a way to programatically add a RibbonTab to a Mircosoft WPF Ribbon? I can't find an example or at least a property to use in neither documentation nor Ribbon's intellisense.

I found many entries all over the web suggesting something like: ribbon.Tabs.Add(...)

Unfortunately "Tabs" doesn't exist in the Ribbon class at all?! Was there an API change I can't find anything about or what's the trick?


Solution

  • The Microsoft WPF Ribbon inherits from Selector, which inherits from ItemsControl. With that in mind, to add a tab programmatically, you would use the Items property to add the new RibbonTab object.

    For example,

    Ribbon.Items.Add(new RibbonTab())