<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:converters="clr-namespace:Fluent.Converters">
    <Style x:Key="RibbonContextualTabGroupStyle"
           TargetType="{x:Type Fluent:RibbonContextualTabGroup}">
        <Setter Property="Template"
                Value="{DynamicResource RibbonContextualTabGroupControlTemplate}" />
        <Setter Property="Width"
                Value="Auto" />
        <Setter Property="HorizontalAlignment"
                Value="Stretch" />
        <Setter Property="Focusable"
                Value="False" />
        <Setter Property="Foreground"
                Value="{DynamicResource Fluent.Ribbon.Brushes.RibbonTabItem.Foreground}" />
        <Setter Property="TabItemSelectedForeground"
                Value="{DynamicResource Fluent.Ribbon.Brushes.RibbonContextualTabGroup.TabItemSelectedForeground}" />
        <Setter Property="TabItemMouseOverForeground"
                Value="{DynamicResource Fluent.Ribbon.Brushes.RibbonContextualTabGroup.TabItemMouseOverForeground}" />
        <Setter Property="TabItemSelectedMouseOverForeground"
                Value="{DynamicResource Fluent.Ribbon.Brushes.RibbonContextualTabGroup.TabItemSelectedMouseOverForeground}" />
    </Style>
    
    <ControlTemplate x:Key="RibbonContextualTabGroupControlTemplate"
                     TargetType="{x:Type Fluent:RibbonContextualTabGroup}">
        <Border x:Name="rootBorder"
                Visibility="{TemplateBinding InnerVisibility}"
                Margin="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Width="Auto">
            <Border BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="0,0"
                    VerticalAlignment="Stretch"
                    Height="Auto">
                <Grid Margin="0"
                      VerticalAlignment="Stretch"
                      Height="Auto">
                    <Rectangle Fill="{TemplateBinding Background}"
                               HorizontalAlignment="Stretch"
                               VerticalAlignment="Stretch"
                               Width="Auto"
                               Height="Auto"
                               OpacityMask="{DynamicResource Fluent.Ribbon.Brushes.RibbonContextualTabGroup.Background.OpacityMask}" />
                    <Rectangle Fill="{TemplateBinding BorderBrush}"
                               HorizontalAlignment="Stretch"
                               VerticalAlignment="Top"
                               Width="Auto"
                               Height="4" />
                    <Grid Margin="0,4,0,0">
                        <TextBlock Text="{TemplateBinding Header}"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Margin="6,0"
                                   TextTrimming="CharacterEllipsis"
                                   Foreground="{TemplateBinding Foreground}" />
                    </Grid>
                </Grid>
            </Border>
        </Border>
    </ControlTemplate>
</ResourceDictionary>