Posted 14 years ago
by Mick

I'm trying to hide tabs in a ContextualTabGroup and it's causing me some strange behavior:
Thank you,
Mick
<ribbon:RibbonWindow
x:Class="ContextMenuSample.MainWindow"
x:Name="MyMainWindow"
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"
Height="350"
Width="525"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="MyRibbon" />
<StackPanel Grid.Row="1">
<Button Content="Click to show context group 1" Click="Button_Click" />
</StackPanel>
</Grid>
</ribbon:RibbonWindow>
using System.Linq;
using System.Windows;
using ActiproSoftware.Windows.Controls.Ribbon.Controls;
namespace ContextMenuSample
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
ContextualTabGroup group = new ContextualTabGroup { Label = "Search" };
Tab tab1 = new Tab { Label = "Category 1" };
Tab tab2 = new Tab { Label = "Category 2" };
group.Items.Add(tab1);
group.Items.Add(tab2);
MyRibbon.ContextualTabGroups.AddRange(new ContextualTabGroup[] { group });
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ContextualTabGroup group = MyRibbon.ContextualTabGroups[0];
group.IsActive = true;
group.Items.OfType<Tab>().First().Visibility = Visibility.Collapsed;
}
}
}
- When I collapse the first tab, the ContextualTabGroup header remains as wide as it would be if the tab were not collapsed.
- When I click on the area of the ribbon where the collapsed tab would be, it throws a WPF error.
- When I change the ".First()" Linq statement to a ".Last()" (collapsing the second tab), the header is the correct size (the tab area is still highlighted though) and problem above goes away.
Thank you,
Mick