WPF Ribbon - ContextualTabGroups not showing up

Mar 12, 2010 at 3:51 PM

I am trying to add a contextual tab group to my ribbon programmatically.  Simply put, the contextual tab group and any ribbon tabs within it just simply don't show up.

Here is my XAML:

<r:RibbonWindow x:Class="wpf_testbed.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:local="clr-namespace:wpf_testbed;assembly="
Width="640" Height="480">

<DockPanel LastChildFill="True">
<r:Ribbon DockPanel.Dock="Top" x:Name="MainRibbonControl" Title="Ribbon Testbed">
<r:RibbonTab Label="FirstTab"></r:RibbonTab>
</r:Ribbon>
</DockPanel>

</r:RibbonWindow>

Here is my C# code:

public Window1()
{
	InitializeComponent();

	RibbonContextualTabGroup tabgroup = new RibbonContextualTabGroup();
	RibbonTab tab = new RibbonTab();

	tabgroup.Label = "Tab Group";
	tab.Label = "Tab";
	tabgroup.Tabs.Add(tab);

	MainRibbonControl.ContextualTabGroups.Add(tabgroup);
}

When I run this, the contextual tab group doesn't show up. In addition to this, If I try to add a contextual tab group even in XAML,
it still doesn't show up. Here is the XAML:

<r:RibbonWindow x:Class="wpf_testbed.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    xmlns:local="clr-namespace:wpf_testbed;assembly="
    Width="640" Height="480">
    
    <DockPanel LastChildFill="True">
        <r:Ribbon DockPanel.Dock="Top" x:Name="MainRibbonControl" Title="Ribbon Testbed">
            <r:RibbonTab Label="FirstTab"></r:RibbonTab>
            <r:Ribbon.ContextualTabGroups>
                <r:RibbonContextualTabGroup Label="Hello">
                    <r:RibbonTab Label="World"></r:RibbonTab>
                    <r:RibbonTab Label="World"></r:RibbonTab>
                    <r:RibbonTab Label="World"></r:RibbonTab>
                </r:RibbonContextualTabGroup>
            </r:Ribbon.ContextualTabGroups>
        </r:Ribbon>
    </DockPanel>
    
</r:RibbonWindow>

Am I doing something wrong?

Thanks for any help.

Apr 23, 2010 at 3:16 PM

ContextualTabGroups only show up if there IsActive-Property is set to true...