<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
                    xmlns:converters="clr-namespace:MahApps.Metro.Converters">

    <converters:ThicknessToDoubleConverter x:Key="BorderThicknessToStrokeThicknessConverter" TakeThicknessSide="Left" />

    <Style x:Key="MahApps.Metro.Styles.FlatButtonFocusVisualStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2"
                               SnapsToDevicePixels="True"
                               Stroke="{DynamicResource FlatButtonForegroundBrush}"
                               StrokeDashArray="1 2"
                               StrokeThickness="1"
                               UseLayoutRounding="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroFlatButton" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource FlatButtonBackgroundBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource MahApps.Metro.Styles.FlatButtonFocusVisualStyle}" />
        <Setter Property="FontSize" Value="{DynamicResource FlatButtonFontSize}" />
        <Setter Property="Foreground" Value="{DynamicResource FlatButtonForegroundBrush}" />
        <Setter Property="Padding" Value="10 5 10 5" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="Border"
                            Margin="0"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="DarkGray" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource FlatButtonPressedBackgroundBrush}" />
                <Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource GrayBrush2}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  style for flat toggle button like MetroFlatButton  -->
    <Style x:Key="MetroFlatToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="{DynamicResource FlatButtonBackgroundBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource MahApps.Metro.Styles.FlatButtonFocusVisualStyle}" />
        <Setter Property="FontSize" Value="{DynamicResource FlatButtonFontSize}" />
        <Setter Property="Foreground" Value="{DynamicResource FlatButtonForegroundBrush}" />
        <Setter Property="Padding" Value="10 5 10 5" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="Border"
                            Margin="0"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
            </Trigger>

            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="DarkGray" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush2}" />
                <Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
            </MultiTrigger>

            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsPressed" Value="True" />
                    <Condition Property="IsChecked" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource FlatButtonPressedBackgroundBrush}" />
                <Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsPressed" Value="True" />
                    <Condition Property="IsChecked" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush3}" />
                <Setter Property="Foreground" Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
            </MultiTrigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource GrayBrush2}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MahApps.Metro.Styles.CircleButtonFocusVisualStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Control}">
                    <Ellipse Margin="3"
                             SnapsToDevicePixels="True"
                             Stroke="{DynamicResource BlackBrush}"
                             StrokeDashArray="2 2"
                             StrokeThickness="1"
                             UseLayoutRounding="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MahApps.Metro.Styles.MetroCircleFocusVisual" BasedOn="{StaticResource MahApps.Metro.Styles.CircleButtonFocusVisualStyle}" />

    <!--  obsolete  -->
    <Style x:Key="MetroCircleButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Control}">
                    <Ellipse Margin="8"
                             SnapsToDevicePixels="True"
                             Stroke="{DynamicResource BlackBrush}"
                             StrokeDashArray="2 2"
                             StrokeThickness="1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  style for WP7/Circle button  -->
    <Style x:Key="MahApps.Metro.Styles.MetroCircleButtonStyle" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource GrayBrush3}" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource MahApps.Metro.Styles.CircleButtonFocusVisualStyle}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}" StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Fill="{DynamicResource BlackBrush}"
                                 Opacity="0"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness, Converter={StaticResource BorderThicknessToStrokeThicknessConverter}}" />
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="0.3"
                                                         Duration="0:0:0" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!--  some out fading  -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.5" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ellipse" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource GrayBrush7}" />
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MetroCircleButtonStyle"
           BasedOn="{StaticResource MahApps.Metro.Styles.MetroCircleButtonStyle}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource MetroCircleButtonFocusVisual}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Ellipse Margin="4"
                                 Fill="{TemplateBinding Background}"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Margin="4"
                                 Fill="{DynamicResource BlackBrush}"
                                 Opacity="0"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Margin="4"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness, Converter={StaticResource BorderThicknessToStrokeThicknessConverter}}" />
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="0.3"
                                                         Duration="0:0:0" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!--  some out fading  -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.5" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ellipse" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource GrayBrush7}" />
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  "Chromeless" style for buttons  -->
    <ControlTemplate x:Key="ChromelessButtonTemplate" TargetType="{x:Type ButtonBase}">
        <Grid Background="{TemplateBinding Background}">
            <ContentPresenter x:Name="PART_ContentPresenter"
                              Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Opacity="0.75"
                              RecognizesAccessKey="True"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="1" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="False">
                <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value=".5" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="#ADADAD" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ChromelessButtonStyle" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource TransparentWhiteBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template" Value="{StaticResource ChromelessButtonTemplate}" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <!--  base button style for min, max and close window buttons  -->
    <Style x:Key="BaseMetroWindowButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource TransparentWhiteBrush}" />
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid Background="{TemplateBinding Background}">
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   Opacity="0.6"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="1" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource SemiTransparentWhiteBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="Foreground" Value="White" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource IdealForegroundDisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MetroBaseWindowButtonStyle"
           BasedOn="{StaticResource BaseMetroWindowButtonStyle}"
           TargetType="{x:Type Button}" />
    <!--  obsolete  -->
    <Style x:Key="MetroWindowButtonStyle"
           BasedOn="{StaticResource MetroBaseWindowButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="MaxHeight" Value="34" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Width" Value="34" />
    </Style>

    <!--  light button style for min, max and close window buttons  -->
    <Style x:Key="LightMetroWindowButtonStyle"
           BasedOn="{StaticResource BaseMetroWindowButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="MaxHeight" Value="34" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Width" Value="34" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource SemiTransparentWhiteBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="Foreground" Value="White" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource IdealForegroundDisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  dark button style for min, max and close window buttons  -->
    <Style x:Key="DarkMetroWindowButtonStyle"
           BasedOn="{StaticResource LightMetroWindowButtonStyle}"
           TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource SemiTransparentGreyBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="Foreground" Value="White" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource DarkIdealForegroundDisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MahApps.Metro.Styles.WindowButton.Close.Light.Win10"
           BasedOn="{StaticResource LightMetroWindowButtonStyle}"
           TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="#E81123" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="#F1707A" />
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource IdealForegroundDisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MahApps.Metro.Styles.WindowButton.Close.Dark.Win10"
           BasedOn="{StaticResource DarkMetroWindowButtonStyle}"
           TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="#E81123" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="#F1707A" />
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource DarkIdealForegroundDisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  style for default button  -->
    <Style x:Key="MahApps.Metro.Styles.MetroButton" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource GrayBrush10}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Upper" />
        <Setter Property="Controls:ControlsHelper.CornerRadius" Value="3" />
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontSize" Value="{DynamicResource UpperCaseContentFontSize}" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="MinHeight" Value="25" />
        <Setter Property="Padding" Value="5 6" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Margin="{TemplateBinding BorderThickness}"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource GrayBrush8}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource GrayBrush7}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonMouseOverBorderBrush}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.7" />
                            <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MetroButton"
           BasedOn="{StaticResource MahApps.Metro.Styles.MetroButton}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Border x:Name="Background"
                                Background="{TemplateBinding Background}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}" />
                        <Border x:Name="Border"
                                Background="{x:Null}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{DynamicResource GrayBrush8}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{DynamicResource GrayBrush7}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonMouseOverBorderBrush}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="2" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.7" />
                            <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SquareButtonStyle" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource WhiteBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BlackBrush}" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Lower" />
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontWeight" Value="SemiBold" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="MinHeight" Value="25" />
        <Setter Property="Padding" Value="5 6" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid Background="{TemplateBinding Background}">
                        <Border x:Name="Background"
                                Background="{x:Null}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.7" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.3" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused" />
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid" />
                                <VisualState x:Name="InvalidFocused" />
                                <VisualState x:Name="InvalidUnfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource GrayBrush8}" />
                            <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BlackBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="AccentedSquareButtonStyle"
           BasedOn="{StaticResource SquareButtonStyle}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
    </Style>

    <Style x:Key="HighlightedSquareButtonStyle"
           BasedOn="{StaticResource SquareButtonStyle}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource HighlightBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid Background="{TemplateBinding Background}">
                        <Border x:Name="Background"
                                Background="{x:Null}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.7" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_ContentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.3" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused" />
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid" />
                                <VisualState x:Name="InvalidFocused" />
                                <VisualState x:Name="InvalidUnfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BlackBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MahApps.Metro.Styles.MetroCircleToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource GrayBrush3}" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource MahApps.Metro.Styles.CircleButtonFocusVisualStyle}" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}" StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Fill="{DynamicResource AccentColorBrush}"
                                 Opacity="0"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness, Converter={StaticResource BorderThicknessToStrokeThicknessConverter}}" />
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="1"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!--  some out fading  -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ellipse" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource GrayBrush7}" />
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MetroCircleToggleButtonStyle"
           BasedOn="{StaticResource MahApps.Metro.Styles.MetroCircleToggleButtonStyle}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource MetroCircleButtonFocusVisual}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Ellipse Margin="4"
                                 Fill="{TemplateBinding Background}"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Margin="4"
                                 Fill="{DynamicResource AccentColorBrush}"
                                 Opacity="0"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Margin="4"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness, Converter={StaticResource BorderThicknessToStrokeThicknessConverter}}" />
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="1"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!--  some out fading  -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ellipse" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource GrayBrush7}" />
                            <Setter TargetName="ellipse" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MahApps.Metro.Styles.MetroToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="{DynamicResource GrayBrush10}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Controls:ControlsHelper.CornerRadius" Value="3" />
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontSize" Value="{DynamicResource UpperCaseContentFontSize}" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="MinHeight" Value="25" />
        <Setter Property="Padding" Value="5 6" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Margin="{TemplateBinding BorderThickness}"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Border" Property="BorderThickness" Value="2" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter TargetName="Border" Property="BorderThickness" Value="2" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.7" />
                            <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="{DynamicResource GrayBrush2}" />
                <Setter Property="BorderBrush" Value="{DynamicResource GrayBrush5}" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource GrayBrush8}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource GrayBrush3}" />
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource GrayBrush7}" />
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource ButtonMouseOverBorderBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  obsolete  -->
    <Style x:Key="MetroToggleButton"
           BasedOn="{StaticResource MahApps.Metro.Styles.MetroToggleButton}"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Border x:Name="Background"
                                Background="{TemplateBinding Background}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}" />
                        <Border x:Name="Border"
                                Background="{x:Null}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.CornerRadius), Mode=OneWay}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                   Padding="{TemplateBinding Padding}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Content="{TemplateBinding Content}"
                                                   ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                   ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   RecognizesAccessKey="True"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.7" />
                            <Setter TargetName="PART_ContentPresenter" Property="Opacity" Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="{DynamicResource GrayBrush2}" />
                <Setter Property="BorderBrush" Value="{DynamicResource GrayBrush5}" />
                <Setter Property="BorderThickness" Value="2" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource GrayBrush8}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsChecked" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource GrayBrush3}" />
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource GrayBrush7}" />
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource ButtonMouseOverBorderBrush}" />
                <Setter Property="BorderThickness" Value="2" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="SquareMetroButton" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource BlackBrush}" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontWeight" Value="SemiBold" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Padding" Value="12 4 12 4" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">

                            <Grid>
                                <Rectangle x:Name="MouseOverRectangle"
                                           Fill="{DynamicResource WhiteBrush}"
                                           Opacity="0" />
                                <Rectangle x:Name="PressedRectangle"
                                           Fill="{DynamicResource BlackBrush}"
                                           Opacity="0" />
                                <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                           Padding="{TemplateBinding Padding}"
                                                           HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                           VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                           Content="{TemplateBinding Content}"
                                                           ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                           ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                           ContentTemplate="{TemplateBinding ContentTemplate}"
                                                           ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                           RecognizesAccessKey="True"
                                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                        </Border>

                        <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   Stroke="White"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="1.5"
                                   StrokeEndLineCap="Square" />
                        <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   Stroke="Black"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="0.5"
                                   StrokeEndLineCap="Square" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverRectangle"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="0.4"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="PressedRectangle"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Border"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="0.5"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

    <Style x:Key="MetroAccentButton"
           BasedOn="{StaticResource SquareMetroButton}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource AccentSelectedColorBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource AccentSelectedColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Grid>
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">

                            <Grid>
                                <Rectangle x:Name="MouseOverRectangle"
                                           Fill="{DynamicResource BlackBrush}"
                                           Opacity="0" />
                                <Rectangle x:Name="PressedRectangle"
                                           Fill="White"
                                           Opacity="0" />
                                <Controls:ContentControlEx x:Name="PART_ContentPresenter"
                                                           Padding="{TemplateBinding Padding}"
                                                           HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                           VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                           Content="{TemplateBinding Content}"
                                                           ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                           ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                           ContentTemplate="{TemplateBinding ContentTemplate}"
                                                           ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                           RecognizesAccessKey="True"
                                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                        </Border>

                        <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   Stroke="White"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="1.5"
                                   StrokeEndLineCap="Square" />
                        <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   Stroke="Black"
                                   StrokeDashArray="1,1"
                                   StrokeDashOffset="0.5"
                                   StrokeEndLineCap="Square" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverRectangle"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="0.4"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="PressedRectangle"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Border"
                                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         To="0.5"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Foreground" Value="Black" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonDropDownStyle"
           BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
           TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource WhiteBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="0"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="Transparent" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource GrayBrush8}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource GrayBrush5}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource GrayBrush10}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonSplitStyle"
           BasedOn="{StaticResource ButtonDropDownStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
    </Style>
    <Style x:Key="ButtonSplitArrowStyle"
           BasedOn="{StaticResource ButtonSplitStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

</ResourceDictionary>