<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
                    xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="AttentionToActionBrush" Color="{StaticResource MaterialDesignShadow}" Opacity=".23" po:Freeze="True" />

    <Style x:Key="MaterialDesignRaisedButton" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
        <Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="16 4 16 4"/>
        <Setter Property="Height" Value="32" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="OnClick">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ClickBorder" Storyboard.TargetProperty="Opacity">
                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0" />
                                <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value=".12">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <CircleEase EasingMode="EaseOut" />
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                                <DiscreteDoubleKeyFrame KeyTime="0:0:0.6" Value=".12" />
                                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <SineEase EasingMode="EaseOut" />
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="ClickBorder">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.81" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border Background="{TemplateBinding Background}" Effect="{StaticResource MaterialDesignShadowDepth1}" />
                        <Border Background="{TemplateBinding Background}" x:Name="border" CornerRadius="2" />
                        <Border Background="White" CornerRadius="2" x:Name="ClickBorder" Opacity="0" RenderTransformOrigin="0.5,0.5" >
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="0"/>
                                    <SkewTransform/>
                                    <RotateTransform/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Border.RenderTransform>
                        </Border>
                        <wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"                                                               
                                                            Feedback="White"
                                                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                            Padding="{TemplateBinding Padding}" 
                                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefaulted" Value="true">
                            <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource AttentionToActionBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="0.23"/>
                        </Trigger>
                        <EventTrigger RoutedEvent="Click">
                            <BeginStoryboard Storyboard="{StaticResource OnClick}"/>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MaterialDesignRaisedLightButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
        <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
    </Style>

    <Style x:Key="MaterialDesignRaisedDarkButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
        <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
    </Style>

    <Style x:Key="MaterialDesignRaisedAccentButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
        <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
    </Style>

    <Style x:Key="MaterialDesignFlatButton" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}"/>
        <Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="16 4 16 4"/>
        <Setter Property="Height" Value="32" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="OnClick">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ClickBorder" Storyboard.TargetProperty="Opacity">
                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0" />
                                <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value="1">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <CircleEase EasingMode="EaseOut" />
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                                <DiscreteDoubleKeyFrame KeyTime="0:0:0.6" Value="1" />
                                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <SineEase EasingMode="EaseOut" />
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="ClickBorder">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.81" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border Background="{DynamicResource MaterialDesignFlatButtonClick}" CornerRadius="2" x:Name="ClickBorder" Opacity="0" RenderTransformOrigin="0.5,0.5" >
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="0"/>
                                    <SkewTransform/>
                                    <RotateTransform/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Border.RenderTransform>
                        </Border>
                        <Border Background="{TemplateBinding Background}" x:Name="border" CornerRadius="2">
                            <wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"                                                               
                                                              Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
                                                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                              Padding="{TemplateBinding Padding}" 
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefaulted" Value="true">
                            <!--Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/-->
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource AttentionToActionBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="0.23"/>
                        </Trigger>
                        <EventTrigger RoutedEvent="Click">
                            <BeginStoryboard Storyboard="{StaticResource OnClick}"/>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MaterialDesignToolButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFlatButton}">
        <Setter Property="Foreground" Value="#616161"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="wpf:RippleAssist.ClipToBounds" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"                                                               
                                                      Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
                                                      HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                      Padding="{TemplateBinding Padding}" 
                                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MaterialDesignToolForegroundButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignToolButton}">
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    </Style>

    <Style x:Key="MaterialDesignFloatingActionButton" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Width" Value="40" />
        <Setter Property="Height" Value="40" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Effect="{DynamicResource MaterialDesignShadowDepth1}"
                                 x:Name="border" />
                        <wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"                                                               
                                                          Feedback="White"
                                                          Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True"
                                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                          Padding="{TemplateBinding Padding}" 
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Ellipse x:Name="GeometryEllipse" Fill="Transparent" IsHitTestVisible="False" Focusable="False" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefaulted" Value="true">
                            <Setter Property="Stroke" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="0.23"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MaterialDesignFloatingActionLightButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
        <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
    </Style>

    <Style x:Key="MaterialDesignFloatingActionDarkButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
        <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
    </Style>

    <Style x:Key="MaterialDesignFloatingActionAccentButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
        <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
    </Style>

</ResourceDictionary>