<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:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">
    <Storyboard x:Key="Fluent.Ribbon.Storyboards.Backstage.IsOpenTrueStoryboard">
        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)">
            <EasingThicknessKeyFrame KeyTime="0"
                                     Value="-125,0,0,0" />
            <EasingThicknessKeyFrame KeyTime="0:0:0.5"
                                     Value="0">
                <EasingThicknessKeyFrame.EasingFunction>
                    <CubicEase EasingMode="EaseOut" />
                </EasingThicknessKeyFrame.EasingFunction>
            </EasingThicknessKeyFrame>
        </ThicknessAnimationUsingKeyFrames>
    </Storyboard>

    <Storyboard x:Key="Fluent.Ribbon.Storyboards.Backstage.IsOpenFalseStoryboard">
        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)">
            <EasingThicknessKeyFrame KeyTime="0"
                                     Value="0" />
            <EasingThicknessKeyFrame KeyTime="0:0:0.3"
                                     Value="-125,0,0,0">
                <EasingThicknessKeyFrame.EasingFunction>
                    <CubicEase EasingMode="EaseOut" />
                </EasingThicknessKeyFrame.EasingFunction>
            </EasingThicknessKeyFrame>
        </ThicknessAnimationUsingKeyFrames>
    </Storyboard>

    <ControlTemplate x:Key="BackstageToggleButtonControlTemplate"
                     TargetType="{x:Type Fluent:Backstage}">
        <Border x:Name="border2"
                MinWidth="60"
                Height="Auto"
                Background="{TemplateBinding Background}"
                Margin="0,0,0,0">
            <Grid>
                <Rectangle x:Name="rectangle" />
                <ContentPresenter x:Name="contentPresenter"
                                  ContentSource="Header"
                                  Margin="10,0,10,0"
                                  VerticalAlignment="Center"
                                  HorizontalAlignment="Center" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Fill"
                        TargetName="rectangle"
                        Value="{DynamicResource HighTransparentWhiteBrush}" />
            </MultiTrigger>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="Opacity"
                        TargetName="border2"
                        Value="0.5" />
                <Setter Property="Effect"
                        TargetName="contentPresenter">
                    <Setter.Value>
                        <Fluent:GrayscaleEffect />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsOpen"
                     Value="True">
                <Setter Property="Visibility"
                        TargetName="rectangle"
                        Value="Collapsed" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True"
                               SourceName="border2" />
                    <Condition Property="IsOpen"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="rectangle"
                        Value="Collapsed" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RibbonBackstageStyle"
           TargetType="{x:Type Fluent:Backstage}">
        <Setter Property="Template" Value="{DynamicResource BackstageToggleButtonControlTemplate}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Fluent:FrameworkHelper.UseLayoutRounding" Value="True" />
        <Setter Property="Header" Value="{Binding Source={x:Static Fluent:RibbonLocalization.Current}, Path=Localization.BackstageButtonText, Mode=OneWay}" />
        <Setter Property="Fluent:KeyTip.Keys" Value="{Binding Source={x:Static Fluent:RibbonLocalization.Current}, Path=Localization.BackstageButtonKeyTip, Mode=OneWay}" />
        <Setter Property="AreAnimationsEnabled" Value="{DynamicResource {x:Static SystemParameters.ClientAreaAnimationKey}}" />
        <Setter Property="Background" Value="{DynamicResource Fluent.Ribbon.Brushes.Backstage.Background}" />
        <Setter Property="Foreground" Value="{DynamicResource Fluent.Ribbon.Brushes.Backstage.Foreground}" />
    </Style>
</ResourceDictionary>