When changing the visibility of a tab within a ContextualTabGroup to Collapsed while application is in backstage and then manually closing the backstage causes a rendering problem of the tab-group.
When changing the visibility within a command that automatically closes the backstage, the problem doesn’t occur.
Used the following code (Within a new project):
App.xaml.cs:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ThemesOfficeThemeCatalogRegistrar.Register();
ThemesMetroThemeCatalogRegistrar.Register();
RibbonThemeCatalogRegistrar.Register();
ThemeManager.CurrentTheme = ThemeName.MetroWhite.ToString();
}
MainWindow.xaml:
<ribbon:RibbonWindow x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
IsGlassEnabled="False">
<ribbon:Ribbon Name="Ribbon">
<ribbon:Ribbon.ApplicationMenu>
<ribbon:Backstage>
<ribbon:BackstageTab Header="Test">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ribbon:Button Grid.Row="0" Label="Hide second tab and close backstage manually"
StaysOpenOnClick="True" Click="CollapseSecondTab" />
<ribbon:Button Grid.Row="1" Label="Hide second tab and close backstage automatically"
StaysOpenOnClick="False" Click="CollapseSecondTab" />
</Grid>
</ribbon:BackstageTab>
</ribbon:Backstage>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:Ribbon.ContextualTabGroups>
<ribbon:ContextualTabGroup Label="Group" IsActive="True">
<ribbon:Tab Label="Tab1"></ribbon:Tab>
<ribbon:Tab Label="Tab2" Name="Tab2"></ribbon:Tab>
</ribbon:ContextualTabGroup>
</ribbon:Ribbon.ContextualTabGroups>
<ribbon:Ribbon.Content>
<ribbon:Button Label="Show second tab" Click="ShowSecondTab"></ribbon:Button>
</ribbon:Ribbon.Content>
</ribbon:Ribbon>
</ribbon:RibbonWindow>
MainWindow.xaml.cs:
private void ShowSecondTab(object sender, ExecuteRoutedEventArgs e)
{
Tab2.Visibility = Visibility.Visible;
}
private void CollapseSecondTab(object sender, ExecuteRoutedEventArgs e)
{
Tab2.Visibility = Visibility.Collapsed;
}
To reproduce the problem make sure both tabs within the tab group are shown. -> Open the backstage -> Click "Hide second tab and close backstage manually"-button. -> Close the backstage.
Any suggestions, why this is happening and how to avoid/solve this problem?