<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:local="clr-namespace:ModernWpf.Controls"
    xmlns:primitives="clr-namespace:ModernWpf.Controls.Primitives">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/ModernWpf;component/Styles/Common.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ui:CornerRadiusFilterConverter x:Key="TopCornerRadiusFilterConverter" Filter="Top" />
    <ui:CornerRadiusFilterConverter x:Key="BottomCornerRadiusFilterConverter" Filter="Bottom" />

    <Thickness x:Key="CommandBarFlyoutAppBarButtonInnerBorderMargin">2</Thickness>
    <Thickness x:Key="CommandBarFlyoutAppBarEllipsisButtonInnerBorderMargin">2,2,6,2</Thickness>

    <Style x:Key="CommandBarFlyoutAppBarButtonStyleBase" TargetType="local:AppBarButton">
        <Setter Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForeground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource CommandBarFlyoutAppBarButtonBorderBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="Width" Value="NaN" />
        <Setter Property="Height" Value="40" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualMargin" Value="0,0,0,2" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AppBarButton">
                    <Grid
                        x:Name="Root"
                        MinWidth="{TemplateBinding MinWidth}"
                        MaxWidth="{TemplateBinding MaxWidth}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="ApplicationViewStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="FullSize" />
                                <VisualState x:Name="Compact" />
                                <VisualState x:Name="LabelOnRight" />
                                <VisualState x:Name="LabelCollapsed" />
                                <VisualState x:Name="Overflow" />
                                <VisualState x:Name="OverflowWithToggleButtons" />
                                <VisualState x:Name="OverflowWithMenuIcons" />
                                <VisualState x:Name="OverflowWithToggleButtonsAndMenuIcons" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="CommonStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver" />
                                <VisualState x:Name="Pressed" />
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="OverflowNormal" />
                                <VisualState x:Name="OverflowPointerOver" />
                                <VisualState x:Name="OverflowPressed" />
                                <!--<VisualState x:Name="OverflowSubMenuOpened" />-->
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="KeyboardAcceleratorTextVisibility">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="KeyboardAcceleratorTextVisibilityListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="KeyboardAcceleratorTextCollapsed" />
                                <VisualState x:Name="KeyboardAcceleratorTextVisible" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="AppBarButtonInnerBorder"
                                Margin="{StaticResource CommandBarFlyoutAppBarButtonInnerBorderMargin}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                ui:FocusVisualHelper.IsTemplateFocusTarget="True">

                            <!--<contract7Present:Border.BackgroundTransition>
                            <contract7Present:BrushTransition Duration="0:0:0.083" />
                            </contract7Present:Border.BackgroundTransition>-->
                        </Border>

                        <Grid x:Name="ContentRoot" Width="40">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Viewbox
                                x:Name="ContentViewbox"
                                Height="16"
                                HorizontalAlignment="Stretch">
                                <ContentPresenter
                                    x:Name="Content"
                                    Content="{TemplateBinding Icon}"
                                    TextElement.Foreground="{TemplateBinding Foreground}" />
                            </Viewbox>
                            <TextBlock
                                x:Name="OverflowTextLabel"
                                Text="{TemplateBinding Label}"
                                Style="{DynamicResource BodyTextBlockStyle}"
                                Foreground="{TemplateBinding Foreground}"
                                FontFamily="{TemplateBinding FontFamily}"
                                TextAlignment="Left"
                                TextWrapping="NoWrap"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Center"
                                Margin="12,0,12,0"
                                Padding="0,5,0,7"
                                Visibility="Collapsed" />
                            <TextBlock
                                x:Name="KeyboardAcceleratorTextLabel"
                                Grid.Column="1"
                                Style="{DynamicResource CaptionTextBlockStyle}"
                                Text="{TemplateBinding InputGestureText}"
                                MinWidth="34"
                                Margin="24,0,12,0"
                                Foreground="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForeground}"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Visibility="Collapsed" />
                            <!--<ui:FontIcon
                            x:Name="SubItemChevron"
                            Grid.Column="2"
                            Glyph="&#xE76C;"
                            FontFamily="{DynamicResource SymbolThemeFontFamily}"
                            FontSize="12"
                            Foreground="{DynamicResource CommandBarFlyoutAppBarButtonSubItemChevronForeground}"
                            Margin="12,0,12,0"
                            VerticalAlignment="Center"
                            Visibility="Collapsed" />-->
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--#region ApplicationViewStates-->
                        <!-- Overflow -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="Overflow">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="ContentViewbox" Property="Margin" Value="12,0,12,0" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <!-- OverflowWithToggleButtons -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="OverflowWithToggleButtons">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Margin" Value="39,0,12,0" />
                        </Trigger>
                        <!-- OverflowWithMenuIcons -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="OverflowWithMenuIcons">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="ContentViewbox" Property="VerticalAlignment" Value="Center" />
                            <Setter TargetName="ContentViewbox" Property="Width" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="Height" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="Margin" Value="12,0,12,0" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Margin" Value="39,0,12,0" />
                        </Trigger>
                        <!-- OverflowWithToggleButtonsAndMenuIcons -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="OverflowWithToggleButtonsAndMenuIcons">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="ContentViewbox" Property="VerticalAlignment" Value="Center" />
                            <Setter TargetName="ContentViewbox" Property="Width" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="Height" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="Margin" Value="39,0,12,0" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Margin" Value="67,0,12,0" />
                        </Trigger>
                        <!--#endregion-->
                        <!--#region CommonStates-->
                        <!-- PointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOver">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                        </Trigger>
                        <!-- Pressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Pressed">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                        </Trigger>
                        <!-- Disabled -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Disabled">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundDisabled}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                        </Trigger>
                        <!-- OverflowPointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowPointerOver">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForegroundPointerOver}" />
                        </Trigger>
                        <!-- OverflowPressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowPressed">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForegroundPressed}" />
                        </Trigger>
                        <!-- OverflowSubMenuOpened -->
                        <!--<Trigger>
                        <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                        <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                        <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                        <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForegroundPointerOver}" />
                        </Trigger>-->
                        <!--#endregion-->
                        <!-- KeyboardAcceleratorTextVisible -->
                        <Trigger SourceName="KeyboardAcceleratorTextVisibilityListener" Property="CurrentStateName" Value="KeyboardAcceleratorTextVisible">
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <!-- HasFlyout -->
                        <!--<Trigger>
                        <Setter TargetName="SubItemChevron" Property="Visibility" Value="Visible" />
                        </Trigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="ToolBar.IsOverflowItem" Value="True">
                <Setter Property="HorizontalAlignment" Value="Stretch" />
                <Setter Property="Width" Value="NaN" />
                <Setter Property="Height" Value="32" />
                <Setter Property="FocusVisualMargin" Value="0" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="CommandBarFlyoutAppBarButtonStyle" TargetType="local:AppBarButton" BasedOn="{StaticResource CommandBarFlyoutAppBarButtonStyleBase}" />

    <Style x:Key="CommandBarFlyoutAppBarToggleButtonStyleBase" TargetType="local:AppBarToggleButton">
        <Setter Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForeground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource CommandBarFlyoutAppBarButtonBorderBrush}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="Width" Value="NaN" />
        <Setter Property="Height" Value="40" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualMargin" Value="0,0,0,2" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AppBarToggleButton">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="Accept">M 6.25 17.138672 L 0.185547 11.064453 L 1.064453 10.185547 L 6.25 15.361328 L 18.935547 2.685547 L 19.814453 3.564453 L 6.25 17.138672 Z</StreamGeometry>
                    </ControlTemplate.Resources>
                    <Grid
                        x:Name="Root"
                        MinWidth="{TemplateBinding MinWidth}"
                        MaxWidth="{TemplateBinding MaxWidth}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="ApplicationViewStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="FullSize" />
                                <VisualState x:Name="Compact" />
                                <VisualState x:Name="LabelOnRight" />
                                <VisualState x:Name="LabelCollapsed" />
                                <VisualState x:Name="Overflow" />
                                <VisualState x:Name="OverflowWithMenuIcons" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="CommonStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver" />
                                <VisualState x:Name="Pressed" />
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="Checked" />
                                <VisualState x:Name="CheckedPointerOver" />
                                <VisualState x:Name="CheckedPressed" />
                                <VisualState x:Name="CheckedDisabled" />
                                <VisualState x:Name="OverflowNormal" />
                                <VisualState x:Name="OverflowPointerOver" />
                                <VisualState x:Name="OverflowPressed" />
                                <VisualState x:Name="OverflowChecked" />
                                <VisualState x:Name="OverflowCheckedPointerOver" />
                                <VisualState x:Name="OverflowCheckedPressed" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="KeyboardAcceleratorTextVisibility">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="KeyboardAcceleratorTextVisibilityListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="KeyboardAcceleratorTextCollapsed" />
                                <VisualState x:Name="KeyboardAcceleratorTextVisible" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="AppBarButtonInnerBorder"
                            Margin="{StaticResource CommandBarFlyoutAppBarButtonInnerBorderMargin}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{TemplateBinding CornerRadius}"
                            ui:FocusVisualHelper.IsTemplateFocusTarget="True">

                            <!--<contract7Present:Border.BackgroundTransition>
                                <contract7Present:BrushTransition Duration="0:0:0.083" />
                            </contract7Present:Border.BackgroundTransition>-->
                        </Border>

                        <Grid x:Name="ContentRoot" Width="40">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ui:FontIconFallback
                                x:Name="OverflowCheckGlyph"
                                Data="{StaticResource Accept}"
                                Foreground="{DynamicResource CommandBarFlyoutAppBarButtonForeground}"
                                FontFamily="{DynamicResource SymbolThemeFontFamily}"
                                FontSize="12"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Margin="15,4,14,4"
                                Opacity="0"
                                Visibility="Collapsed" />
                            <Viewbox
                                x:Name="ContentViewbox"
                                Height="16"
                                HorizontalAlignment="Stretch">
                                <ContentPresenter
                                    x:Name="Content"
                                    Content="{TemplateBinding Icon}"
                                    TextElement.Foreground="{TemplateBinding Foreground}" />
                            </Viewbox>
                            <TextBlock
                                x:Name="OverflowTextLabel"
                                Text="{TemplateBinding Label}"
                                Style="{DynamicResource BodyTextBlockStyle}"
                                Foreground="{TemplateBinding Foreground}"
                                FontFamily="{TemplateBinding FontFamily}"
                                TextAlignment="Left"
                                TextWrapping="NoWrap"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Center"
                                Margin="39,0,12,0"
                                Padding="0,5,0,7"
                                Visibility="Collapsed" />
                            <TextBlock
                                x:Name="KeyboardAcceleratorTextLabel"
                                Grid.Column="1"
                                Style="{DynamicResource CaptionTextBlockStyle}"
                                Text="{TemplateBinding InputGestureText}"
                                MinWidth="34"
                                Margin="24,0,12,0"
                                Foreground="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForeground}"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Visibility="Collapsed" />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--#region ApplicationViewStates-->
                        <!-- Overflow -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="Overflow">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <!-- OverflowWithMenuIcons -->
                        <Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="OverflowWithMenuIcons">
                            <Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
                            <Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
                            <Setter TargetName="ContentViewbox" Property="Visibility" Value="Visible" />
                            <Setter TargetName="ContentViewbox" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="ContentViewbox" Property="VerticalAlignment" Value="Center" />
                            <Setter TargetName="ContentViewbox" Property="MaxWidth" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="MaxHeight" Value="16" />
                            <Setter TargetName="ContentViewbox" Property="Margin" Value="39,0,12,0" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
                            <Setter TargetName="OverflowTextLabel" Property="Margin" Value="67,0,12,0" />
                        </Trigger>
                        <!--#endregion-->
                        <!--#region CommonStates-->
                        <!-- PointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOver">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                        </Trigger>
                        <!-- Pressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Pressed">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                        </Trigger>
                        <!-- Disabled -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Disabled">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundDisabled}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                        </Trigger>
                        <!-- Checked -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Checked">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundChecked}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundChecked}" />
                        </Trigger>
                        <!-- CheckedPointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="CheckedPointerOver">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundCheckedPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundCheckedPointerOver}" />
                        </Trigger>
                        <!-- CheckedPressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="CheckedPressed">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundCheckedPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundCheckedPressed}" />
                        </Trigger>
                        <!-- CheckedDisabled -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="CheckedDisabled">
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundDisabled}" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Opacity" Value="1" />
                        </Trigger>
                        <!-- OverflowPointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowPointerOver">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForegroundPointerOver}" />
                        </Trigger>
                        <!-- OverflowPressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowPressed">
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonKeyboardTextLabelForegroundPressed}" />
                        </Trigger>
                        <!-- OverflowChecked -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowChecked">
                            <Setter TargetName="OverflowCheckGlyph" Property="Opacity" Value="1" />
                        </Trigger>
                        <!-- OverflowCheckedPointerOver -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowCheckedPointerOver">
                            <Setter TargetName="OverflowCheckGlyph" Property="Opacity" Value="1" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
                        </Trigger>
                        <!-- OverflowCheckedPressed -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="OverflowCheckedPressed">
                            <Setter TargetName="OverflowCheckGlyph" Property="Opacity" Value="1" />
                            <Setter TargetName="OverflowCheckGlyph" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
                            <Setter TargetName="Content" Property="TextElement.Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
                        </Trigger>
                        <!--#endregion-->
                        <!-- KeyboardAcceleratorTextVisible -->
                        <Trigger SourceName="KeyboardAcceleratorTextVisibilityListener" Property="CurrentStateName" Value="KeyboardAcceleratorTextVisible">
                            <Setter TargetName="KeyboardAcceleratorTextLabel" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="ToolBar.IsOverflowItem" Value="True">
                <Setter Property="HorizontalAlignment" Value="Stretch" />
                <Setter Property="Width" Value="NaN" />
                <Setter Property="Height" Value="32" />
                <Setter Property="FocusVisualMargin" Value="0" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="CommandBarFlyoutAppBarToggleButtonStyle" TargetType="local:AppBarToggleButton" BasedOn="{StaticResource CommandBarFlyoutAppBarToggleButtonStyleBase}" />

    <Style x:Key="CommandBarFlyoutCommandBarOverflowPresenterStyle" TargetType="primitives:CommandBarOverflowPresenter">
        <Setter Property="Background" Value="{DynamicResource CommandBarFlyoutButtonBackground}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="MinWidth" Value="136" />
        <Setter Property="MaxWidth" Value="440" />
        <Setter Property="MaxHeight" Value="480" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Once" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="primitives:CommandBarOverflowPresenter">
                    <Border
                        x:Name="LayoutRoot"
                        Background="{TemplateBinding Background}"
                        Padding="{TemplateBinding Padding}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        SnapsToDevicePixels="True">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="DisplayModeStates">
                                <VisualState x:Name="DisplayModeDefault" />
                                <VisualState x:Name="FullWidthOpenDown" />
                                <VisualState x:Name="FullWidthOpenUp" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ScrollViewer
                            Content="{TemplateBinding Content}"
                            Margin="{TemplateBinding BorderThickness}"
                            Padding="0,4,0,4"
                            HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                            VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="primitives:CommandBarFlyoutToolBar">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="primitives:CommandBarFlyoutToolBar">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="More">M 2.5 8.75 C 2.675781 8.75 2.838542 8.782553 2.988281 8.847656 C 3.138021 8.912761 3.269857 9 3.383789 9.116211 C 3.497721 9.230144 3.58724 9.361979 3.652344 9.511719 C 3.717448 9.661459 3.75 9.824219 3.75 10 C 3.75 10.175781 3.717448 10.338542 3.652344 10.488281 C 3.58724 10.638021 3.497721 10.769857 3.383789 10.883789 C 3.269857 11 3.138021 11.08724 2.988281 11.152344 C 2.838542 11.217448 2.675781 11.25 2.5 11.25 C 2.324219 11.25 2.161458 11.217448 2.011719 11.152344 C 1.861979 11.08724 1.730143 11 1.616211 10.883789 C 1.502279 10.769857 1.41276 10.638021 1.347656 10.488281 C 1.282552 10.338542 1.25 10.175781 1.25 10 C 1.25 9.824219 1.282552 9.661459 1.347656 9.511719 C 1.41276 9.361979 1.502279 9.230144 1.616211 9.116211 C 1.730143 9 1.861979 8.912761 2.011719 8.847656 C 2.161458 8.782553 2.324219 8.75 2.5 8.75 Z M 10 8.75 C 10.175781 8.75 10.338541 8.782553 10.488281 8.847656 C 10.638021 8.912761 10.769856 9 10.883789 9.116211 C 11 9.230144 11.087239 9.361979 11.152344 9.511719 C 11.217447 9.661459 11.25 9.824219 11.25 10 C 11.25 10.175781 11.217447 10.338542 11.152344 10.488281 C 11.087239 10.638021 11 10.769857 10.883789 10.883789 C 10.769856 11 10.638021 11.08724 10.488281 11.152344 C 10.338541 11.217448 10.175781 11.25 10 11.25 C 9.824219 11.25 9.661458 11.217448 9.511719 11.152344 C 9.361979 11.08724 9.230143 11 9.116211 10.883789 C 9 10.769857 8.91276 10.638021 8.847656 10.488281 C 8.782552 10.338542 8.75 10.175781 8.75 10 C 8.75 9.824219 8.782552 9.661459 8.847656 9.511719 C 8.91276 9.361979 9 9.230144 9.116211 9.116211 C 9.230143 9 9.361979 8.912761 9.511719 8.847656 C 9.661458 8.782553 9.824219 8.75 10 8.75 Z M 17.5 8.75 C 17.675781 8.75 17.838541 8.782553 17.988281 8.847656 C 18.13802 8.912761 18.269855 9 18.383789 9.116211 C 18.497721 9.230144 18.587238 9.361979 18.652344 9.511719 C 18.717447 9.661459 18.75 9.824219 18.75 10 C 18.75 10.175781 18.717447 10.338542 18.652344 10.488281 C 18.587238 10.638021 18.497721 10.769857 18.383789 10.883789 C 18.269855 11 18.13802 11.08724 17.988281 11.152344 C 17.838541 11.217448 17.675781 11.25 17.5 11.25 C 17.324219 11.25 17.161457 11.217448 17.011719 11.152344 C 16.861979 11.08724 16.730143 11 16.616211 10.883789 C 16.502277 10.769857 16.41276 10.638021 16.347656 10.488281 C 16.282551 10.338542 16.25 10.175781 16.25 10 C 16.25 9.824219 16.282551 9.661459 16.347656 9.511719 C 16.41276 9.361979 16.502277 9.230144 16.616211 9.116211 C 16.730143 9 16.861979 8.912761 17.011719 8.847656 C 17.161457 8.782553 17.324219 8.75 17.5 8.75 Z</StreamGeometry>
                    </ControlTemplate.Resources>
                    <Border
                        x:Name="LayoutRoot"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        SnapsToDevicePixels="True">
                        <Border.Resources>
                            <primitives:CommandBarFlyoutCommandBarTemplateSettingsProxy
                                x:Key="TemplateSettingsProxy"
                                FlyoutTemplateSettings="{Binding FlyoutTemplateSettings, RelativeSource={RelativeSource TemplatedParent}, Mode=OneTime}" />
                            <Style TargetType="local:AppBarButton" BasedOn="{StaticResource CommandBarFlyoutAppBarButtonStyle}" />
                            <Style TargetType="local:AppBarToggleButton" BasedOn="{StaticResource CommandBarFlyoutAppBarToggleButtonStyle}" />
                            <Storyboard x:Key="OpeningStoryboard" FillBehavior="Stop">
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <!--
                            The closing animation plays the opening animation in reverse and then snaps to a position where
                            the clip will fully hide the flyout, in preparation for closing the flyout.
                            As such, it's expected and normal that we use OpenAnimation* template settings properties
                            in the closing animation.
                            -->
                            <Storyboard x:Key="ClosingStoryboard">
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.CloseAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OpenAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.CloseAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="CollapsedToExpandedUpStoryboard">
                                <DoubleAnimation
                                    Storyboard.TargetName="OuterOverflowContentRoot"
                                    Storyboard.TargetProperty="Opacity"
                                    To="1"
                                    Duration="0" />
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="Width">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandedWidth}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MoreButtonTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PrimaryItemsRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondaryItemsControl" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="ExpandedUpToCollapsedStoryboard" FillBehavior="Stop">
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRoot" Storyboard.TargetProperty="Opacity">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="Width">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandedWidth}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MoreButtonTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="0" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationHoldPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="CollapsedToExpandedDownStoryboard">
                                <DoubleAnimation
                                    Storyboard.TargetName="OuterOverflowContentRoot"
                                    Storyboard.TargetProperty="Opacity"
                                    To="1"
                                    Duration="0" />
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="Width">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandedWidth}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MoreButtonTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationStartPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PrimaryItemsRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRoot" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondaryItemsControl" Storyboard.TargetProperty="CornerRadius">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="ExpandedDownToCollapsedStoryboard" FillBehavior="Stop">
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OuterOverflowContentRoot" Storyboard.TargetProperty="Opacity">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="Width">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandedWidth}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MoreButtonTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="0" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionMoreButtonAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationEndPosition}" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationStartPosition}" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource ControlFastAnimationAfterDuration}" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationHoldPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="ExpandedUpStoryboard">
                                <DoubleAnimation
                                    Storyboard.TargetName="MoreButtonTransform"
                                    Storyboard.TargetProperty="X"
                                    To="0"
                                    Duration="0" />
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandUpAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="ExpandedDownStoryboard">
                                <DoubleAnimation
                                    Storyboard.TargetName="MoreButtonTransform"
                                    Storyboard.TargetProperty="X"
                                    To="0"
                                    Duration="0" />
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="X">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OverflowContentRootClipTransform" Storyboard.TargetProperty="Y">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandDownAnimationEndPosition}" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </Border.Resources>
                        <VisualStateManager.CustomVisualStateManager>
                            <ui:SimpleVisualStateManager />
                        </VisualStateManager.CustomVisualStateManager>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ExpansionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="Collapsed" To="ExpandedUp" Storyboard="{StaticResource CollapsedToExpandedUpStoryboard}" />
                                    <VisualTransition From="ExpandedUp" To="Collapsed" Storyboard="{StaticResource ExpandedUpToCollapsedStoryboard}" />
                                    <VisualTransition From="Collapsed" To="ExpandedDown" Storyboard="{StaticResource CollapsedToExpandedDownStoryboard}" />
                                    <VisualTransition From="ExpandedDown" To="Collapsed" Storyboard="{StaticResource ExpandedDownToCollapsedStoryboard}" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Collapsed">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="OuterOverflowContentRoot"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0"
                                            Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ExpandedUp" Storyboard="{StaticResource ExpandedUpStoryboard}" />
                                <VisualState x:Name="ExpandedDown" Storyboard="{StaticResource ExpandedDownStoryboard}" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="AvailableCommandsStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="AvailableCommandsStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="BothCommands" />
                                <VisualState x:Name="PrimaryCommandsOnly" />
                                <VisualState x:Name="SecondaryCommandsOnly" />
                            </VisualStateGroup>
                            <VisualStateGroup>
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="CombinedStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Default" />
                                <VisualState x:Name="ExpandedUpWithPrimaryCommands" />
                                <VisualState x:Name="ExpandedDownWithPrimaryCommands" />
                                <VisualState x:Name="ExpandedUpWithoutPrimaryCommands" />
                                <VisualState x:Name="ExpandedDownWithoutPrimaryCommands" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border
                            x:Name="OuterContentRoot"
                            VerticalAlignment="Top"
                            Margin="{TemplateBinding Padding}"
                            MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.CurrentWidth}"
                            Height="{TemplateBinding Height}"
                            CornerRadius="{Binding ElementName=LayoutRoot, Path=CornerRadius}">
                            <Border.Clip>
                                <RectangleGeometry
                                    x:Name="OuterContentRootClip"
                                    Rect="{Binding Source={StaticResource TemplateSettingsProxy}, Path=FlyoutTemplateSettings.ContentClipRect}">
                                    <RectangleGeometry.Transform>
                                        <TranslateTransform x:Name="OuterContentRootClipTransform" />
                                    </RectangleGeometry.Transform>
                                </RectangleGeometry>
                            </Border.Clip>
                            <Grid x:Name="ContentRoot"
                                  Background="{TemplateBinding Background}">
                                <Grid.Clip>
                                    <RectangleGeometry
                                        x:Name="ContentRootClip"
                                        Rect="{Binding Source={StaticResource TemplateSettingsProxy}, Path=FlyoutTemplateSettings.ContentClipRect}">
                                        <RectangleGeometry.Transform>
                                            <!--
                                            If you have a value set by a binding and then animate that value,
                                            the animation will clear the binding.  Because of that, we need to have
                                            two translate transforms - one that we bind to a property,
                                            and another that we can animate.
                                            -->
                                            <TransformGroup>
                                                <TranslateTransform X="{Binding Source={StaticResource TemplateSettingsProxy}, Path=FlyoutTemplateSettings.WidthExpansionDelta}" />
                                                <TranslateTransform x:Name="ContentRootClipTransform" />
                                            </TransformGroup>
                                        </RectangleGeometry.Transform>
                                    </RectangleGeometry>
                                </Grid.Clip>
                                <Border
                                    x:Name="PrimaryItemsRoot"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="{TemplateBinding CornerRadius}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" MinWidth="3"/>
                                        </Grid.ColumnDefinitions>
                                        <primitives:CommandBarPanel
                                            x:Name="PART_ToolBarPanel"
                                            Height="40"
                                            Margin="3,3,0,3"
                                            Grid.Column="0"
                                            HorizontalAlignment="Left"
                                            IsItemsHost="true"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        <ToggleButton
                                            x:Name="MoreButton"
                                            IsEnabled="{TemplateBinding HasOverflowItems}"
                                            Foreground="{TemplateBinding Foreground}"
                                            Style="{DynamicResource CommandBarFlyoutEllipsisButtonStyle}"
                                            Grid.Column="1"
                                            IsTabStop="False"
                                            ui:ControlHelper.CornerRadius="{TemplateBinding CornerRadius}"
                                            Visibility="{TemplateBinding EffectiveOverflowButtonVisibility}"
                                            IsChecked="{Binding Path=IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                            ClickMode="Press"
                                            ui:FocusVisualHelper.FocusVisualMargin="0,0,0,2">
                                            <ToggleButton.RenderTransform>
                                                <TranslateTransform x:Name="MoreButtonTransform" />
                                            </ToggleButton.RenderTransform>
                                            <ui:FontIconFallback
                                                x:Name="EllipsisIcon"
                                                HorizontalAlignment="Center"
                                                VerticalAlignment="Center"
                                                FontFamily="{DynamicResource SymbolThemeFontFamily}"
                                                FontSize="16"
                                                Data="{StaticResource More}" />
                                        </ToggleButton>
                                    </Grid>
                                </Border>
                                <ui:PopupEx
                                    x:Name="OverflowPopup"
                                    AllowsTransparency="true"
                                    Placement="Bottom"
                                    IsOpen="{Binding Path=IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}"
                                    StaysOpen="false"
                                    Focusable="false"
                                    PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
                                    <Border
                                        x:Name="OuterOverflowContentRoot"
                                        Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.ExpandedWidth}">
                                        <Border.Clip>
                                            <RectangleGeometry
                                                x:Name="OuterOverflowContentRootClip"
                                                Rect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OverflowContentClipRect}">
                                                <RectangleGeometry.Transform>
                                                    <TranslateTransform x:Name="OuterOverflowContentRootClipTransform" />
                                                </RectangleGeometry.Transform>
                                            </RectangleGeometry>
                                        </Border.Clip>
                                        <Border
                                            x:Name="OverflowContentRoot"
                                            HorizontalAlignment="Stretch"
                                            Background="{TemplateBinding Background}"
                                            CornerRadius="{Binding ElementName=OuterOverflowContentRoot, Path=CornerRadius}">
                                            <Border.Clip>
                                                <RectangleGeometry
                                                    x:Name="OverflowContentRootClip"
                                                    Rect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.OverflowContentClipRect}">
                                                    <RectangleGeometry.Transform>
                                                        <!--
                                                        If you have a value set by a binding and then animate that value,
                                                        the animation will clear the binding.  Because of that, we need to have
                                                        two translate transforms - one that we bind to a property,
                                                        and another that we can animate.
                                                        -->
                                                        <TransformGroup>
                                                            <TranslateTransform X="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FlyoutTemplateSettings.WidthExpansionDelta}" />
                                                            <TranslateTransform x:Name="OverflowContentRootClipTransform" />
                                                        </TransformGroup>
                                                    </RectangleGeometry.Transform>
                                                </RectangleGeometry>
                                            </Border.Clip>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <primitives:CommandBarOverflowPresenter
                                                    Grid.Row="1"
                                                    x:Name="SecondaryItemsControl"
                                                    Style="{TemplateBinding OverflowPresenterStyle}"
                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                    BorderThickness="{DynamicResource CommandBarFlyoutBorderThemeThickness}"
                                                    IsTabStop="False">
                                                    <primitives:CommandBarOverflowPanel
                                                        x:Name="PART_ToolBarOverflowPanel"
                                                        Focusable="False"
                                                        FocusVisualStyle="{x:Null}"
                                                        KeyboardNavigation.TabNavigation="Once"
                                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                                </primitives:CommandBarOverflowPresenter>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </ui:PopupEx>
                            </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="EllipsisIcon" Property="Foreground" Value="{DynamicResource CommandBarEllipsisIconForegroundDisabled}" />
                        </Trigger>
                        <!-- PrimaryCommandsOnly -->
                        <Trigger SourceName="AvailableCommandsStatesListener" Property="CurrentStateName" Value="PrimaryCommandsOnly">
                            <Setter TargetName="OverflowContentRoot" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <!-- SecondaryCommandsOnly -->
                        <Trigger SourceName="AvailableCommandsStatesListener" Property="CurrentStateName" Value="SecondaryCommandsOnly">
                            <Setter TargetName="PrimaryItemsRoot" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="OverflowPopup" Property="Placement" Value="{x:Static PlacementMode.Relative}" />
                            <Setter TargetName="PART_ToolBarOverflowPanel" Property="Focusable" Value="True" />
                        </Trigger>
                        <!-- ExpandedUpWithPrimaryCommands -->
                        <Trigger SourceName="CombinedStatesListener" Property="CurrentStateName" Value="ExpandedUpWithPrimaryCommands">
                            <Setter TargetName="SecondaryItemsControl" Property="BorderThickness" Value="{DynamicResource CommandBarFlyoutBorderUpThemeThickness}" />
                            <Setter TargetName="LayoutRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                            <Setter TargetName="PrimaryItemsRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                            <Setter TargetName="OuterOverflowContentRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                            <Setter TargetName="SecondaryItemsControl" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                        </Trigger>
                        <!-- ExpandedDownWithPrimaryCommands -->
                        <Trigger SourceName="CombinedStatesListener" Property="CurrentStateName" Value="ExpandedDownWithPrimaryCommands">
                            <Setter TargetName="SecondaryItemsControl" Property="BorderThickness" Value="{DynamicResource CommandBarFlyoutBorderDownThemeThickness}" />
                            <Setter TargetName="LayoutRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                            <Setter TargetName="PrimaryItemsRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopCornerRadiusFilterConverter}}" />
                            <Setter TargetName="OuterOverflowContentRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                            <Setter TargetName="SecondaryItemsControl" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
                        </Trigger>
                        <!-- ExpandedUpWithoutPrimaryCommands -->
                        <Trigger SourceName="CombinedStatesListener" Property="CurrentStateName" Value="ExpandedUpWithoutPrimaryCommands">
                            <Setter TargetName="SecondaryItemsControl" Property="BorderThickness" Value="{DynamicResource CommandBarFlyoutBorderThemeThickness}" />
                            <Setter TargetName="LayoutRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="PrimaryItemsRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="OuterOverflowContentRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="SecondaryItemsControl" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>
                        <!-- ExpandedDownWithoutPrimaryCommands -->
                        <Trigger SourceName="CombinedStatesListener" Property="CurrentStateName" Value="ExpandedDownWithoutPrimaryCommands">
                            <Setter TargetName="SecondaryItemsControl" Property="BorderThickness" Value="{DynamicResource CommandBarFlyoutBorderThemeThickness}" />
                            <Setter TargetName="LayoutRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="PrimaryItemsRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="OuterOverflowContentRoot" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Setter TargetName="SecondaryItemsControl" Property="CornerRadius" Value="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="primitives:CommandBarFlyoutCommandBar">
        <Setter Property="Background" Value="{DynamicResource AcrylicInAppFillColorDefaultBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource SystemControlTransientBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource CommandBarFlyoutBorderThemeThickness}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="DefaultLabelPosition" Value="Collapsed" />
        <Setter Property="MaxWidth" Value="440" />
        <Setter Property="Height" Value="48" />
        <Setter Property="IsDynamicOverflowEnabled" Value="False" />
        <Setter Property="CommandBarOverflowPresenterStyle" Value="{StaticResource CommandBarFlyoutCommandBarOverflowPresenterStyle}" />
        <Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="primitives:CommandBarFlyoutCommandBar">
                    <primitives:CommandBarFlyoutToolBar
                        x:Name="PART_ToolBar"
                        Background="{TemplateBinding Background}"
                        Foreground="{TemplateBinding Foreground}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        IsTabStop="{TemplateBinding IsTabStop}"
                        VerticalAlignment="{TemplateBinding VerticalAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                        DefaultLabelPosition="{TemplateBinding DefaultLabelPosition}"
                        MaxWidth="{TemplateBinding MaxWidth}"
                        Height="{TemplateBinding Height}"
                        IsDynamicOverflowEnabled="{TemplateBinding IsDynamicOverflowEnabled}"
                        OverflowButtonVisibility="{TemplateBinding OverflowButtonVisibility}"
                        OverflowPresenterStyle="{TemplateBinding CommandBarOverflowPresenterStyle}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        IsOverflowOpen="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>