<commit_before>﻿<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:conv="clr-namespace:MahApps.Metro.Converters"
                    xmlns:Behaviours="clr-namespace:MahApps.Metro.Behaviours"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

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

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <conv:ToUpperConverter x:Key="ToUpperConverter" />

    <ControlTemplate x:Key="WindowTemplateKey"
                     TargetType="{x:Type Controls:MetroWindow}">
        <Grid>
            <AdornerDecorator>
                <Grid Background="{TemplateBinding Background}">
                    <Grid.ColumnDefinitions>
                        <!-- icon -->
                        <ColumnDefinition Width="Auto" />
                        <!-- left window commands -->
                        <ColumnDefinition Width="Auto" />
                        <!-- title -->
                        <ColumnDefinition Width="*" />
                        <!-- right window commands -->
                        <ColumnDefinition Width="Auto" />
                        <!-- min,max,close buttons -->
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Rectangle x:Name="PART_WindowTitleBackground"
                               Focusable="False"
                               Fill="{TemplateBinding WindowTitleBrush}"
                               Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                               Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
                               Grid.Column="0"
                               Grid.ColumnSpan="5"
                               StrokeThickness="0" />

                    <!-- icon -->
                    <ContentControl x:Name="PART_Icon"
                                    Focusable="False"
                                    Grid.Row="0"
                                    Grid.Column="0"
                                    Panel.ZIndex="1"
                                    Content="{TemplateBinding Icon}"
                                    ContentTemplate="{TemplateBinding IconTemplate}"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    MinWidth="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Visibility="{TemplateBinding ShowIconOnTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the left window commands -->
                    <ContentPresenter x:Name="PART_LeftWindowCommands"
                                      Focusable="False"
                                      Content="{Binding LeftWindowCommands, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Panel.ZIndex="1"
                                      Grid.Row="0"
                                      Grid.Column="1"
                                      Grid.RowSpan="2"
                                      VerticalAlignment="Top"
                                      Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the title bar -->
                    <ContentControl x:Name="PART_TitleBar"
                                    Focusable="False"
                                    Grid.Row="0"
                                    Grid.Column="2"
                                    Content="{TemplateBinding Title}"
                                    ContentTemplate="{TemplateBinding TitleTemplate}"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <ContentControl.Foreground>
                            <MultiBinding Converter="{x:Static Converters:BackgroundToForegroundConverter.Instance}">
                                <Binding ElementName="PART_WindowTitleBackground"
                                         Path="Fill"
                                         Mode="OneWay" />
                                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                         Path="TitleForeground"
                                         Mode="OneWay" />
                            </MultiBinding>
                        </ContentControl.Foreground>
                    </ContentControl>

                    <!-- the right window commands -->
                    <ContentPresenter x:Name="PART_RightWindowCommands"
                                      Focusable="False"
                                      Content="{Binding RightWindowCommands, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Panel.ZIndex="1"
                                      Grid.Row="0"
                                      Grid.Column="3"
                                      Grid.RowSpan="2"
                                      VerticalAlignment="Top"
                                      Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the window button commands -->
                    <Controls:WindowButtonCommands x:Name="PART_WindowButtonCommands"
                                                   Focusable="False"
                                                   Panel.ZIndex="1"
                                                   Grid.Row="0"
                                                   Grid.Column="4"
                                                   Grid.RowSpan="2"
                                                   VerticalAlignment="Top"
                                                   Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />

                    <!-- the main window content -->
                    <Controls:MetroContentControl Grid.Row="1"
                                                  Grid.Column="0"
                                                  Grid.ColumnSpan="5"
                                                  IsTabStop="False"
                                                  FocusVisualStyle="{x:Null}"
                                                  OnlyLoadTransition="True"
                                                  TransitionsEnabled="{TemplateBinding WindowTransitionsEnabled}">
                        <ContentPresenter />
                    </Controls:MetroContentControl>

                    <!-- disables the main content when a modal flyout is shown -->
                    <Rectangle Grid.Row="0"
                               Grid.RowSpan="2"
                               Grid.ColumnSpan="5"
                               Grid.Column="0"
                               Name="PART_FlyoutModal"
                               Fill="{DynamicResource BlackColorBrush}"
                               Opacity="0.5"
                               Visibility="Hidden" />

                    <!-- flyouts -->
                    <ContentControl Grid.Row="0"
                                    Grid.Column="0"
                                    Grid.ColumnSpan="5"
                                    Grid.RowSpan="2"
                                    Panel.ZIndex="2"
                                    Focusable="False"
                                    KeyboardNavigation.TabNavigation="None"
                                    Content="{Binding Flyouts, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    VerticalAlignment="Stretch" />

                    <!-- Used to create that overlay effect. Can be used for anything. -->
                    <Grid Grid.Row="0"
                          Grid.Column="0"
                          Grid.ColumnSpan="5"
                          Grid.RowSpan="2"
                          Panel.ZIndex="3"
                          Focusable="False"
                          FocusVisualStyle="{x:Null}"
                          x:Name="PART_OverlayBox"
                          Background="{DynamicResource BlackColorBrush}"
                          Opacity="0"
                          Visibility="Hidden" />

                    <Grid Grid.Row="0"
                          Grid.Column="0"
                          Grid.ColumnSpan="5"
                          Grid.RowSpan="2"
                          Panel.ZIndex="4"
                          FocusVisualStyle="{x:Null}"
                          x:Name="PART_MetroDialogContainer" />
                </Grid>
            </AdornerDecorator>

            <Border x:Name="PART_Border"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch" />
            <ResizeGrip x:Name="WindowResizeGrip"
                        HorizontalAlignment="Right"
                        IsTabStop="false"
                        Visibility="Collapsed"
                        VerticalAlignment="Bottom" />
        </Grid>

        <ControlTemplate.Resources>
            <Storyboard x:Key="OverlayFastSemiFadeIn"
                        BeginTime="0:0:0"
                        AccelerationRatio=".97"
                        Storyboard.TargetProperty="Opacity"
                        SpeedRatio="2.7">
                <DoubleAnimation To=".7" />
            </Storyboard>
            <Storyboard x:Key="OverlayFastSemiFadeOut"
                        BeginTime="0:0:0"
                        AccelerationRatio=".97"
                        Storyboard.TargetProperty="Opacity"
                        SpeedRatio="2.7">
                <DoubleAnimation To="0.0" />
            </Storyboard>
        </ControlTemplate.Resources>
        <ControlTemplate.Triggers>
            <!-- handle active/inactive state -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsActive"
                               Value="False" />
                    <Condition Property="GlowBrush"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Border"
                        Property="BorderBrush"
                        Value="{Binding Path=NonActiveBorderBrush, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
            </MultiTrigger>
            <Trigger Property="IsActive"
                     Value="False">
                <Setter TargetName="PART_WindowTitleBackground"
                        Property="Fill"
                        Value="{Binding Path=NonActiveWindowTitleBrush, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
            </Trigger>
            <Trigger Property="BorderBrush"
                     Value="{x:Null}">
                <Setter TargetName="PART_Border"
                        Property="Visibility"
                        Value="Collapsed" />
            </Trigger>
            <!-- no icon and no icon content template -> collapse the icon content control -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Icon"
                               Value="{x:Null}" />
                    <Condition Property="IconTemplate"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Icon"
                        Property="Visibility"
                        Value="Collapsed" />
                <Setter TargetName="PART_Icon"
                        Property="MinWidth"
                        Value="0" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode"
                               Value="CanResizeWithGrip" />
                    <Condition Property="WindowState"
                               Value="Normal" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="WindowResizeGrip"
                        Value="Visible" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type Controls:MetroWindow}">
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush"
                Value="Transparent" />
        <Setter Property="UseLayoutRounding"
                Value="True" />
        <Setter Property="WindowTitleBrush"
                Value="{DynamicResource WindowTitleColorBrush}" />
        <Setter Property="TextElement.FontSize"
                Value="{DynamicResource ContentFontSize}" />
        <Setter Property="Background"
                Value="{DynamicResource WhiteBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="WindowMinButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="WindowMaxButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="WindowCloseButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="Behaviours:StylizedBehaviors.Behaviors">
            <Setter.Value>
                <Behaviours:StylizedBehaviorCollection>
                    <Behaviours:BorderlessWindowBehavior />
                    <Behaviours:WindowsSettingBehaviour />
                    <Behaviours:GlowWindowBehavior />
                </Behaviours:StylizedBehaviorCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="TitleForeground"
                Value="{DynamicResource IdealForegroundColorBrush}" />
        <Setter Property="Template"
                Value="{StaticResource WindowTemplateKey}" />
        <Setter Property="TitleTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{TemplateBinding Content}"
                               TextTrimming="CharacterEllipsis"
                               VerticalAlignment="Center"
                               Margin="8 -1 0 0"
                               FontSize="{DynamicResource WindowTitleFontSize}"
                               FontFamily="{DynamicResource HeaderFontFamily}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=TitleCaps, Mode=OneWay, Converter={StaticResource ToUpperConverter}}"
                         Value="True">
                <Setter Property="TitleTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Converter={StaticResource ToUpperConverter}}"
                                       TextTrimming="CharacterEllipsis"
                                       VerticalAlignment="Center"
                                       Margin="8 -1 0 0"
                                       FontSize="{DynamicResource WindowTitleFontSize}"
                                       FontFamily="{DynamicResource HeaderFontFamily}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Icon, Mode=OneWay, Converter={x:Static Converters:IsNullConverter.Instance}}"
                         Value="False">
                <Setter Property="IconTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Controls:MultiFrameImage Width="{TemplateBinding Width}"
                                                      Height="{TemplateBinding Height}"
                                                      Source="{TemplateBinding Content}"
                                                      RenderOptions.EdgeMode="{Binding IconEdgeMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                                      RenderOptions.BitmapScalingMode="{Binding IconBitmapScalingMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Controls:WindowCommands}">
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:WindowCommands">
                    <ControlTemplate.Resources>
                        <ResourceDictionary>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Foreground"
                                        Value="{DynamicResource BlackBrush}" />
                                <Setter Property="Background"
                                        Value="{DynamicResource TransparentWhiteBrush}" />
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                                <Setter Property="VerticalContentAlignment"
                                        Value="Center" />
                                <Setter Property="Padding"
                                        Value="1" />
                                <Setter Property="Focusable"
                                        Value="False" />
                                <Setter Property="FocusVisualStyle"
                                        Value="{x:Null}" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Grid Background="{TemplateBinding Background}">
                                                <ContentPresenter x:Name="contentPresenter"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                                  RecognizesAccessKey="True"
                                                                  Opacity="0.75"
                                                                  Margin="9,1,9,1" />

                                                <Rectangle x:Name="border"
                                                           Visibility="{Binding ShowSeparators, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                           SnapsToDevicePixels="True"
                                                           IsHitTestVisible="False"
                                                           Opacity="0.25"
                                                           Width="1"
                                                           Height="15"
                                                           VerticalAlignment="Stretch"
                                                           HorizontalAlignment="Right"
                                                           Fill="{TemplateBinding Foreground}"
                                                           Margin="8,0,0,0" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsMouseOver"
                                                         Value="False">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value=".5" />
                                                </Trigger>
                                                <Trigger Property="IsEnabled"
                                                         Value="false">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource GrayBrush4}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                 Value="True">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource IdealForegroundColorBrush}" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                            <Style TargetType="{x:Type ToggleButton}">
                                <!--Modified version of spiritdead's code-->
                                <Setter Property="Foreground"
                                        Value="{DynamicResource BlackBrush}" />
                                <Setter Property="Background"
                                        Value="{DynamicResource TransparentWhiteBrush}" />
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                                <Setter Property="VerticalContentAlignment"
                                        Value="Center" />
                                <Setter Property="Padding"
                                        Value="1" />
                                <Setter Property="Focusable"
                                        Value="False" />
                                <Setter Property="FocusVisualStyle"
                                        Value="{x:Null}" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                                            <Grid Background="{TemplateBinding Background}">
                                                <ContentPresenter x:Name="contentPresenter"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                                  RecognizesAccessKey="True"
                                                                  Opacity=".5"
                                                                  Margin="9,1,9,1" />

                                                <Rectangle x:Name="border"
                                                           Visibility="{Binding ShowSeparators, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                           SnapsToDevicePixels="True"
                                                           IsHitTestVisible="False"
                                                           Opacity=".2"
                                                           Width="1"
                                                           Height="15"
                                                           VerticalAlignment="Stretch"
                                                           HorizontalAlignment="Right"
                                                           Fill="{TemplateBinding Foreground}"
                                                           Margin="8,0,0,0" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsChecked"
                                                         Value="true">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsEnabled"
                                                         Value="false">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource GrayBrush4}" />
                                                </Trigger>
                                                <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                             Value="True">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource IdealForegroundColorBrush}" />
                                                </DataTrigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ResourceDictionary>
                    </ControlTemplate.Resources>
                    <ItemsPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource IdealForegroundColorBrush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="False">
                <Setter Property="Background"
                        Value="Transparent" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Controls:WindowButtonCommands}">
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:WindowButtonCommands">
                    <StackPanel Orientation="Horizontal">

                        <Button x:Name="PART_Min"
                                Focusable="False"
                                Style="{Binding WindowMinButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Minimize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsMinButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="MIN">
                                    <Binding Path="ShowMinButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="ResizeMode"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <Path Data="F1M0,6L0,9 9,9 9,6 0,6z"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>

                        <Button x:Name="PART_Max"
                                Focusable="False"
                                Style="{Binding WindowMaxButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Maximize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsMaxRestoreButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="MAX">
                                    <Binding Path="ShowMaxRestoreButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="ResizeMode"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <!-- normal state -->
                            <Path x:Name="PART_MaxPath"
                                  Width="10"
                                  Height="10"
                                  Data="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>

                        <Button x:Name="PART_Close"
                                Focusable="False"
                                RenderOptions.EdgeMode="Aliased"
                                Style="{Binding WindowCloseButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Close, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsCloseButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="CLOSE">
                                    <Binding Path="ShowCloseButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <Path Data="M 10.009,1.704 L 8.331,0.026 5.03,3.327 1.703,0 0,1.704 3.326,5.031 0.025,8.332 1.703,10.009 5.004,6.708 8.305,10.009 10.009,8.305 6.708,5.005"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Path=WindowState}"
                                     Value="Maximized">
                            <Setter TargetName="PART_MaxPath"
                                    Property="Data"
                                    Value="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
                            <Setter TargetName="PART_Max"
                                    Property="ToolTip"
                                    Value="{Binding Restore, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource IdealForegroundColorBrush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="False">
                <Setter Property="Background"
                        Value="Transparent" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
<commit_msg>#1902 set VerticalContentAlignment instead  VerticalAlignment for WindowCommands<commit_after>﻿<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:conv="clr-namespace:MahApps.Metro.Converters"
                    xmlns:Behaviours="clr-namespace:MahApps.Metro.Behaviours"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

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

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <conv:ToUpperConverter x:Key="ToUpperConverter" />

    <ControlTemplate x:Key="WindowTemplateKey"
                     TargetType="{x:Type Controls:MetroWindow}">
        <Grid>
            <AdornerDecorator>
                <Grid Background="{TemplateBinding Background}">
                    <Grid.ColumnDefinitions>
                        <!-- icon -->
                        <ColumnDefinition Width="Auto" />
                        <!-- left window commands -->
                        <ColumnDefinition Width="Auto" />
                        <!-- title -->
                        <ColumnDefinition Width="*" />
                        <!-- right window commands -->
                        <ColumnDefinition Width="Auto" />
                        <!-- min,max,close buttons -->
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Rectangle x:Name="PART_WindowTitleBackground"
                               Focusable="False"
                               Fill="{TemplateBinding WindowTitleBrush}"
                               Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                               Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
                               Grid.Column="0"
                               Grid.ColumnSpan="5"
                               StrokeThickness="0" />

                    <!-- icon -->
                    <ContentControl x:Name="PART_Icon"
                                    Focusable="False"
                                    Grid.Row="0"
                                    Grid.Column="0"
                                    Panel.ZIndex="1"
                                    Content="{TemplateBinding Icon}"
                                    ContentTemplate="{TemplateBinding IconTemplate}"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    MinWidth="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Visibility="{TemplateBinding ShowIconOnTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the left window commands -->
                    <ContentPresenter x:Name="PART_LeftWindowCommands"
                                      Focusable="False"
                                      Content="{Binding LeftWindowCommands, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Panel.ZIndex="1"
                                      Grid.Row="0"
                                      Grid.Column="1"
                                      Grid.RowSpan="2"
                                      VerticalAlignment="Top"
                                      Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the title bar -->
                    <ContentControl x:Name="PART_TitleBar"
                                    Focusable="False"
                                    Grid.Row="0"
                                    Grid.Column="2"
                                    Content="{TemplateBinding Title}"
                                    ContentTemplate="{TemplateBinding TitleTemplate}"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <ContentControl.Foreground>
                            <MultiBinding Converter="{x:Static Converters:BackgroundToForegroundConverter.Instance}">
                                <Binding ElementName="PART_WindowTitleBackground"
                                         Path="Fill"
                                         Mode="OneWay" />
                                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                         Path="TitleForeground"
                                         Mode="OneWay" />
                            </MultiBinding>
                        </ContentControl.Foreground>
                    </ContentControl>

                    <!-- the right window commands -->
                    <ContentPresenter x:Name="PART_RightWindowCommands"
                                      Focusable="False"
                                      Content="{Binding RightWindowCommands, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Panel.ZIndex="1"
                                      Grid.Row="0"
                                      Grid.Column="3"
                                      Grid.RowSpan="2"
                                      VerticalAlignment="Top"
                                      Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                      Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" />

                    <!-- the window button commands -->
                    <Controls:WindowButtonCommands x:Name="PART_WindowButtonCommands"
                                                   Focusable="False"
                                                   Panel.ZIndex="1"
                                                   Grid.Row="0"
                                                   Grid.Column="4"
                                                   Grid.RowSpan="2"
                                                   VerticalAlignment="Top"
                                                   Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />

                    <!-- the main window content -->
                    <Controls:MetroContentControl Grid.Row="1"
                                                  Grid.Column="0"
                                                  Grid.ColumnSpan="5"
                                                  IsTabStop="False"
                                                  FocusVisualStyle="{x:Null}"
                                                  OnlyLoadTransition="True"
                                                  TransitionsEnabled="{TemplateBinding WindowTransitionsEnabled}">
                        <ContentPresenter />
                    </Controls:MetroContentControl>

                    <!-- disables the main content when a modal flyout is shown -->
                    <Rectangle Grid.Row="0"
                               Grid.RowSpan="2"
                               Grid.ColumnSpan="5"
                               Grid.Column="0"
                               Name="PART_FlyoutModal"
                               Fill="{DynamicResource BlackColorBrush}"
                               Opacity="0.5"
                               Visibility="Hidden" />

                    <!-- flyouts -->
                    <ContentControl Grid.Row="0"
                                    Grid.Column="0"
                                    Grid.ColumnSpan="5"
                                    Grid.RowSpan="2"
                                    Panel.ZIndex="2"
                                    Focusable="False"
                                    KeyboardNavigation.TabNavigation="None"
                                    Content="{Binding Flyouts, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                    VerticalAlignment="Stretch" />

                    <!-- Used to create that overlay effect. Can be used for anything. -->
                    <Grid Grid.Row="0"
                          Grid.Column="0"
                          Grid.ColumnSpan="5"
                          Grid.RowSpan="2"
                          Panel.ZIndex="3"
                          Focusable="False"
                          FocusVisualStyle="{x:Null}"
                          x:Name="PART_OverlayBox"
                          Background="{DynamicResource BlackColorBrush}"
                          Opacity="0"
                          Visibility="Hidden" />

                    <Grid Grid.Row="0"
                          Grid.Column="0"
                          Grid.ColumnSpan="5"
                          Grid.RowSpan="2"
                          Panel.ZIndex="4"
                          FocusVisualStyle="{x:Null}"
                          x:Name="PART_MetroDialogContainer" />
                </Grid>
            </AdornerDecorator>

            <Border x:Name="PART_Border"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch" />
            <ResizeGrip x:Name="WindowResizeGrip"
                        HorizontalAlignment="Right"
                        IsTabStop="false"
                        Visibility="Collapsed"
                        VerticalAlignment="Bottom" />
        </Grid>

        <ControlTemplate.Resources>
            <Storyboard x:Key="OverlayFastSemiFadeIn"
                        BeginTime="0:0:0"
                        AccelerationRatio=".97"
                        Storyboard.TargetProperty="Opacity"
                        SpeedRatio="2.7">
                <DoubleAnimation To=".7" />
            </Storyboard>
            <Storyboard x:Key="OverlayFastSemiFadeOut"
                        BeginTime="0:0:0"
                        AccelerationRatio=".97"
                        Storyboard.TargetProperty="Opacity"
                        SpeedRatio="2.7">
                <DoubleAnimation To="0.0" />
            </Storyboard>
        </ControlTemplate.Resources>
        <ControlTemplate.Triggers>
            <!-- handle active/inactive state -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsActive"
                               Value="False" />
                    <Condition Property="GlowBrush"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Border"
                        Property="BorderBrush"
                        Value="{Binding Path=NonActiveBorderBrush, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
            </MultiTrigger>
            <Trigger Property="IsActive"
                     Value="False">
                <Setter TargetName="PART_WindowTitleBackground"
                        Property="Fill"
                        Value="{Binding Path=NonActiveWindowTitleBrush, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
            </Trigger>
            <Trigger Property="BorderBrush"
                     Value="{x:Null}">
                <Setter TargetName="PART_Border"
                        Property="Visibility"
                        Value="Collapsed" />
            </Trigger>
            <!-- no icon and no icon content template -> collapse the icon content control -->
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Icon"
                               Value="{x:Null}" />
                    <Condition Property="IconTemplate"
                               Value="{x:Null}" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Icon"
                        Property="Visibility"
                        Value="Collapsed" />
                <Setter TargetName="PART_Icon"
                        Property="MinWidth"
                        Value="0" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode"
                               Value="CanResizeWithGrip" />
                    <Condition Property="WindowState"
                               Value="Normal" />
                </MultiTrigger.Conditions>
                <Setter Property="Visibility"
                        TargetName="WindowResizeGrip"
                        Value="Visible" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type Controls:MetroWindow}">
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush"
                Value="Transparent" />
        <Setter Property="UseLayoutRounding"
                Value="True" />
        <Setter Property="WindowTitleBrush"
                Value="{DynamicResource WindowTitleColorBrush}" />
        <Setter Property="TextElement.FontSize"
                Value="{DynamicResource ContentFontSize}" />
        <Setter Property="Background"
                Value="{DynamicResource WhiteBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="WindowMinButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="WindowMaxButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="WindowCloseButtonStyle"
                Value="{DynamicResource MetroWindowButtonStyle}" />
        <Setter Property="Behaviours:StylizedBehaviors.Behaviors">
            <Setter.Value>
                <Behaviours:StylizedBehaviorCollection>
                    <Behaviours:BorderlessWindowBehavior />
                    <Behaviours:WindowsSettingBehaviour />
                    <Behaviours:GlowWindowBehavior />
                </Behaviours:StylizedBehaviorCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="TitleForeground"
                Value="{DynamicResource IdealForegroundColorBrush}" />
        <Setter Property="Template"
                Value="{StaticResource WindowTemplateKey}" />
        <Setter Property="TitleTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{TemplateBinding Content}"
                               TextTrimming="CharacterEllipsis"
                               VerticalAlignment="Center"
                               Margin="8 -1 0 0"
                               FontSize="{DynamicResource WindowTitleFontSize}"
                               FontFamily="{DynamicResource HeaderFontFamily}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=TitleCaps, Mode=OneWay, Converter={StaticResource ToUpperConverter}}"
                         Value="True">
                <Setter Property="TitleTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Converter={StaticResource ToUpperConverter}}"
                                       TextTrimming="CharacterEllipsis"
                                       VerticalAlignment="Center"
                                       Margin="8 -1 0 0"
                                       FontSize="{DynamicResource WindowTitleFontSize}"
                                       FontFamily="{DynamicResource HeaderFontFamily}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Icon, Mode=OneWay, Converter={x:Static Converters:IsNullConverter.Instance}}"
                         Value="False">
                <Setter Property="IconTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Controls:MultiFrameImage Width="{TemplateBinding Width}"
                                                      Height="{TemplateBinding Height}"
                                                      Source="{TemplateBinding Content}"
                                                      RenderOptions.EdgeMode="{Binding IconEdgeMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                                      RenderOptions.BitmapScalingMode="{Binding IconBitmapScalingMode, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Controls:WindowCommands}">
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:WindowCommands">
                    <ControlTemplate.Resources>
                        <ResourceDictionary>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Foreground"
                                        Value="{DynamicResource BlackBrush}" />
                                <Setter Property="Background"
                                        Value="{DynamicResource TransparentWhiteBrush}" />
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                                <Setter Property="VerticalContentAlignment"
                                        Value="Center" />
                                <Setter Property="Padding"
                                        Value="1" />
                                <Setter Property="Focusable"
                                        Value="False" />
                                <Setter Property="FocusVisualStyle"
                                        Value="{x:Null}" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Grid Background="{TemplateBinding Background}">
                                                <ContentPresenter x:Name="contentPresenter"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                                  RecognizesAccessKey="True"
                                                                  Opacity="0.75"
                                                                  Margin="9,1,9,1" />

                                                <Rectangle x:Name="border"
                                                           Visibility="{Binding ShowSeparators, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                           SnapsToDevicePixels="True"
                                                           IsHitTestVisible="False"
                                                           Opacity="0.25"
                                                           Width="1"
                                                           Height="15"
                                                           VerticalAlignment="Stretch"
                                                           HorizontalAlignment="Right"
                                                           Fill="{TemplateBinding Foreground}"
                                                           Margin="8,0,0,0" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsMouseOver"
                                                         Value="False">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value=".5" />
                                                </Trigger>
                                                <Trigger Property="IsEnabled"
                                                         Value="false">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource GrayBrush4}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                 Value="True">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource IdealForegroundColorBrush}" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                            <Style TargetType="{x:Type ToggleButton}">
                                <!--Modified version of spiritdead's code-->
                                <Setter Property="Foreground"
                                        Value="{DynamicResource BlackBrush}" />
                                <Setter Property="Background"
                                        Value="{DynamicResource TransparentWhiteBrush}" />
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                                <Setter Property="VerticalContentAlignment"
                                        Value="Center" />
                                <Setter Property="Padding"
                                        Value="1" />
                                <Setter Property="Focusable"
                                        Value="False" />
                                <Setter Property="FocusVisualStyle"
                                        Value="{x:Null}" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                                            <Grid Background="{TemplateBinding Background}">
                                                <ContentPresenter x:Name="contentPresenter"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                                  RecognizesAccessKey="True"
                                                                  Opacity=".5"
                                                                  Margin="9,1,9,1" />

                                                <Rectangle x:Name="border"
                                                           Visibility="{Binding ShowSeparators, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                           SnapsToDevicePixels="True"
                                                           IsHitTestVisible="False"
                                                           Opacity=".2"
                                                           Width="1"
                                                           Height="15"
                                                           VerticalAlignment="Stretch"
                                                           HorizontalAlignment="Right"
                                                           Fill="{TemplateBinding Foreground}"
                                                           Margin="8,0,0,0" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsChecked"
                                                         Value="true">
                                                    <Setter TargetName="contentPresenter"
                                                            Property="Opacity"
                                                            Value="1" />
                                                </Trigger>
                                                <Trigger Property="IsEnabled"
                                                         Value="false">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource GrayBrush4}" />
                                                </Trigger>
                                                <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowCommands}}}"
                                                             Value="True">
                                                    <Setter Property="Foreground"
                                                            Value="{DynamicResource IdealForegroundColorBrush}" />
                                                </DataTrigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ResourceDictionary>
                    </ControlTemplate.Resources>
                    <ItemsPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource IdealForegroundColorBrush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="False">
                <Setter Property="Background"
                        Value="Transparent" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Controls:WindowButtonCommands}">
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:WindowButtonCommands">
                    <StackPanel Orientation="Horizontal">

                        <Button x:Name="PART_Min"
                                Focusable="False"
                                Style="{Binding WindowMinButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Minimize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsMinButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="MIN">
                                    <Binding Path="ShowMinButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="ResizeMode"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <Path Data="F1M0,6L0,9 9,9 9,6 0,6z"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>

                        <Button x:Name="PART_Max"
                                Focusable="False"
                                Style="{Binding WindowMaxButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Maximize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsMaxRestoreButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="MAX">
                                    <Binding Path="ShowMaxRestoreButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="ResizeMode"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <!-- normal state -->
                            <Path x:Name="PART_MaxPath"
                                  Width="10"
                                  Height="10"
                                  Data="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>

                        <Button x:Name="PART_Close"
                                Focusable="False"
                                RenderOptions.EdgeMode="Aliased"
                                Style="{Binding WindowCloseButtonStyle, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                ToolTip="{Binding Close, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}"
                                IsEnabled="{Binding IsCloseButtonEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                            <Button.Visibility>
                                <MultiBinding Converter="{x:Static conv:ResizeModeMinMaxButtonVisibilityConverter.Instance}"
                                              ConverterParameter="CLOSE">
                                    <Binding Path="ShowCloseButton"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                    <Binding Path="UseNoneWindowStyle"
                                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}"
                                             Mode="OneWay" />
                                </MultiBinding>
                            </Button.Visibility>
                            <Path Data="M 10.009,1.704 L 8.331,0.026 5.03,3.327 1.703,0 0,1.704 3.326,5.031 0.025,8.332 1.703,10.009 5.004,6.708 8.305,10.009 10.009,8.305 6.708,5.005"
                                  SnapsToDevicePixels="True"
                                  Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}" />
                        </Button>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Path=WindowState}"
                                     Value="Maximized">
                            <Setter TargetName="PART_MaxPath"
                                    Property="Data"
                                    Value="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
                            <Setter TargetName="PART_Max"
                                    Property="ToolTip"
                                    Value="{Binding Restore, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:WindowButtonCommands}}}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource IdealForegroundColorBrush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}"
                         Value="False">
                <Setter Property="Background"
                        Value="Transparent" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>

{'fraction_non_alphanumeric': 0.08288222199736922, 'fraction_numerical': 0.0077405646058889, 'mean_word_length': 1.015627389996431, 'pattern_counts': {'":': 0, '<': 625, '<?xml version=': 0, '>': 627, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 696, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6943631', 'n_tokens_mistral': 15749, 'n_tokens_neox': 14017, 'n_words': 2314}