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

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="AccentedDialogSquareButton"
           BasedOn="{StaticResource AccentedSquareButtonStyle}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
    </Style>

    <Style x:Key="AccentedDialogHighlightedSquareButton"
           BasedOn="{StaticResource HighlightedSquareButtonStyle}"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
    </Style>

    <Storyboard x:Key="DialogShownStoryboard">
        <DoubleAnimation AccelerationRatio=".9"
                         BeginTime="0:0:0"
                         Storyboard.TargetProperty="Opacity"
                         To="1"
                         Duration="0:0:0.2" />
    </Storyboard>

    <Storyboard x:Key="DialogCloseStoryboard">
        <DoubleAnimation AccelerationRatio=".9"
                         BeginTime="0:0:0"
                         Storyboard.TargetProperty="Opacity"
                         To="0"
                         Duration="0:0:0.2" />
    </Storyboard>

    <ControlTemplate x:Key="MetroDialogTemplate" TargetType="{x:Type Dialogs:BaseMetroDialog}">
        <Grid Background="{TemplateBinding Background}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ContentPresenter Grid.Row="0"
                              AutomationProperties.Name="Dialog top"
                              Content="{TemplateBinding DialogTop}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" />
                    <ColumnDefinition Width="50*" />
                    <ColumnDefinition Width="25*" />
                </Grid.ColumnDefinitions>
                <!--  Content area  -->
                <Grid Grid.Column="1" Margin="{TemplateBinding Padding}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <TextBlock x:Name="PART_Title"
                               Grid.Row="0"
                               AutomationProperties.Name="Dialog title"
                               FontSize="{TemplateBinding DialogTitleFontSize}"
                               Foreground="{TemplateBinding Foreground}"
                               Text="{TemplateBinding Title}"
                               TextWrapping="Wrap" />
                    <ContentPresenter Grid.Row="1"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      AutomationProperties.Name="Dialog content"
                                      Content="{TemplateBinding Content}"
                                      ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </Grid>
            </Grid>
            <ContentPresenter Grid.Row="2"
                              AutomationProperties.Name="Dialog bottom"
                              Content="{TemplateBinding DialogBottom}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Title" Value="{x:Null}">
                <Setter TargetName="PART_Title" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <EventTrigger RoutedEvent="Loaded">
                <EventTrigger.Actions>
                    <BeginStoryboard Storyboard="{StaticResource DialogShownStoryboard}" />
                </EventTrigger.Actions>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="MahApps.Metro.Styles.MetroDialog" TargetType="{x:Type Dialogs:BaseMetroDialog}">
        <Style.Resources>
            <Style BasedOn="{StaticResource SquareButtonStyle}" TargetType="{x:Type Button}">
                <Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
            </Style>
        </Style.Resources>
        <Setter Property="Background" Value="{DynamicResource WhiteColorBrush}" />
        <Setter Property="DialogMessageFontSize" Value="{DynamicResource DialogMessageFontSize}" />
        <Setter Property="DialogTitleFontSize" Value="{DynamicResource DialogTitleFontSize}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="KeyboardNavigation.ControlTabNavigation" Value="Cycle" />
        <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Cycle" />
        <Setter Property="Opacity" Value="0" />
        <Setter Property="Padding" Value="0 10 0 0" />
        <Setter Property="Template" Value="{StaticResource MetroDialogTemplate}" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
    </Style>
</ResourceDictionary>