<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <Style x:Key="MainWindowStyle" TargetType="WindowBase">
        <Setter Property="Background" Value="{DynamicResource WindowBackgourndBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
        <Setter Property="TextOptions.TextRenderingMode" Value="Auto" />
        <Setter Property="WindowChrome.WindowChrome">
            <Setter.Value>
                <WindowChrome CaptionHeight="25" CornerRadius="0" ResizeBorderThickness="4"
                              NonClientFrameEdges ="None" UseAeroCaptionButtons="False" GlassFrameThickness="0"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type WindowBase}">
                    <ControlTemplate.Resources>
                        <sys:Boolean x:Key="True">True</sys:Boolean>
                    </ControlTemplate.Resources>
                    <AdornerDecorator>
                        <Border x:Name="WindowBorder" BorderBrush="{DynamicResource PopupBorderBrush}" CornerRadius="0"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}">
                            <Grid>
                                <ContentPresenter Margin="0,0,0,0"/>
                                <DockPanel DockPanel.Dock="Top" LastChildFill="False">
                                    <DockPanel DockPanel.Dock="Top" LastChildFill="False">
                                        <TextBlock Text="{TemplateBinding Title}" DockPanel.Dock="Left" Margin="10,3,0,0" VerticalAlignment="Center"
                                                   Opacity="0.75" Style="{DynamicResource BaseTextBlockStyle}" x:Name="PART_TextTitle" />
                                        <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Margin="0,3,5,0">
                                            <Button Style="{DynamicResource WindowBarButton}" Content="0" x:Name="PART_ButtonMinimize"/>
                                            <Button Style="{DynamicResource WindowBarButton}" Content="1" x:Name="PART_ButtonMaximize" />
                                            <Button Style="{DynamicResource WindowBarButton}" Content="r" x:Name="PART_ButtonClose"/>
                                        </StackPanel>
                                    </DockPanel>
                                </DockPanel>
                            </Grid>
                        </Border>
                    </AdornerDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter Property="Content" Value="2" TargetName="PART_ButtonMaximize"/>
                            <Setter Property="Padding" Value="8" TargetName="WindowBorder"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding HasChildWindow, Mode=OneWay, RelativeSource={RelativeSource Self}, TargetNullValue=False}" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" TargetName="WindowBorder"/>
                            <Setter Property="Opacity" Value="0.4" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>