<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:fa="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
                    xmlns:local="clr-namespace:pkNX.WinForms"
                    xmlns:darkBlendTheme="clr-namespace:DarkBlendTheme" xmlns:System="clr-namespace:System;assembly=System.Runtime"
                    mc:Ignorable="d">

    <!--Converters-->
    <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter"/>

    <!-- DefaultValues -->
    <System:Double x:Key="DefaultInspectorHeight">24</System:Double>
    <System:Int32 x:Key="ToolTipInitialShowDelay">2000</System:Int32>
    <System:Int32 x:Key="ToolTipBetweenShowDelay">2000</System:Int32>

    <FontFamily x:Key="DefaultFont">Segoe UI</FontFamily>

    <!--Colors-->

    <Color x:Key="SelectionColor">#5781BA</Color>
    <Color x:Key="InactiveSelectionColor">#335C85</Color>

    <Color x:Key="PressedColor">#E7E7E7</Color>
    <Color x:Key="BorderColor">#111111</Color>

    <Color x:Key="ForegroundColor">#EFEFEF</Color>
    <Color x:Key="ForegroundColor.Disabled">#878787</Color>
    <Color x:Key="ForegroundColor.Header">#303030</Color>

    <!-- Base color theme (https://color.adobe.com/create/color-wheel) -->
    <Color x:Key="DarkestColor">#2B2B2B</Color>
    
    <Color x:Key="DarkColor">#333333</Color>
    <Color x:Key="SecondaryColor">#474747</Color>
    <Color x:Key="PrimaryColor">#3B3B3B</Color>
    <Color x:Key="LightColor">#878787</Color>
    <Color x:Key="HighlightColor">#C7C7C7</Color>

    <!-- Darken Base 60% https://mdigi.tools/darken-color/ -->
    <Color x:Key="DarkestColor.Disabled">#111111</Color>
    
    <Color x:Key="DarkColor.Disabled">#141414</Color>
    <Color x:Key="PrimaryColor.Disabled">#181818</Color>
    <Color x:Key="SecondaryColor.Disabled">#1c1c1c</Color>
    <Color x:Key="LightColor.Disabled">#363636</Color>

    <!-- Lighten Base 10% https://mdigi.tools/lighten-color/ -->
    <Color x:Key="DarkestColor.Highlight">#404040</Color>
    
    <Color x:Key="DarkColor.Highlight">#474747</Color>
    <Color x:Key="SecondaryColor.Highlight">#595959</Color>
    <Color x:Key="PrimaryColor.Highlight">#4f4f4f</Color>
    <Color x:Key="LightColor.Highlight">#939393</Color>

    <!-- Lighten Base 5% https://mdigi.tools/lighten-color/ -->
    <Color x:Key="DarkestColor.Pressed">#363636</Color>
    <Color x:Key="DarkColor.Pressed">#3d3d3d</Color>
    <Color x:Key="PrimaryColor.Pressed">#454545</Color>
    <Color x:Key="SecondaryColor.Pressed">#505050</Color>
    <Color x:Key="LightColor.Pressed">#8d8d8d</Color>

    <!--Brushes-->
    <SolidColorBrush x:Key="TestBrush" Color="Red"/>
    <SolidColorBrush x:Key="ForegroundBrush" Color="{StaticResource ForegroundColor }"/>
    <SolidColorBrush x:Key="ForegroundBrush.Disabled" Color="{StaticResource ForegroundColor.Disabled}"/>
    <SolidColorBrush x:Key="ForegroundBrush.Highlight" Color="{StaticResource ForegroundColor}"/>

    <SolidColorBrush x:Key="SelectionBrush" Color="{StaticResource SelectionColor}"/>

    <SolidColorBrush x:Key="InputBorder" Color="{StaticResource BorderColor}" />
    <SolidColorBrush x:Key="DarkestBorder" Color="{StaticResource DarkestColor}" />

    <SolidColorBrush x:Key="Window.Background" Color="{StaticResource DarkColor}"/>

    <SolidColorBrush x:Key="DockWindow.Background" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="DockWindow.Border" Color="{StaticResource SecondaryColor}" />

    <SolidColorBrush x:Key="TabItem.Default.Background" Color="{StaticResource DarkColor}"/>
    <SolidColorBrush x:Key="TabItem.Default.BorderBrush" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="TabItem.Hot.Background" Color="{StaticResource SecondaryColor.Highlight}"/>
    <SolidColorBrush x:Key="TabItem.Hot.BorderBrush" Color="{StaticResource PrimaryColor.Highlight}"/>
    <SolidColorBrush x:Key="TabItem.Selected.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="TabItem.Disabled.Background" Color="{StaticResource DarkColor.Disabled}"/>
    <SolidColorBrush x:Key="TabItem.Disabled.BorderBrush" Color="{StaticResource PrimaryColor.Disabled}"/>

    <SolidColorBrush x:Key="ScrollViewer.Background" Color="Transparent" />

    <SolidColorBrush x:Key="ScrollBar.Default.Background" Color="{StaticResource SecondaryColor}" />
    <SolidColorBrush x:Key="ScrollBar.Disabled.Background" Color="{StaticResource SecondaryColor.Disabled}"/>
    <SolidColorBrush x:Key="ScrollBar.Thumb.Background" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="ScrollBar.Thumb.Hot" Color="{StaticResource HighlightColor}"/>
    <SolidColorBrush x:Key="ScrollBar.Thumb.Pressed" Color="{StaticResource PressedColor}"/>
    <SolidColorBrush x:Key="ScrollBar.Corner.Background" Color="{StaticResource LightColor}"/>

    <SolidColorBrush x:Key="TextBox.Border" Color="{StaticResource BorderColor}" />
    <SolidColorBrush x:Key="TextBox.Background" Color="{StaticResource DarkColor}" />
    <SolidColorBrush x:Key="TextBox.Disabled.Foreground" Color="{StaticResource ForegroundColor.Disabled}" />
    <SolidColorBrush x:Key="TextBox.Disabled.Background" Color="{StaticResource DarkColor.Disabled}" />
    <SolidColorBrush x:Key="InactiveSelectionHighlightBrush" Color="{StaticResource InactiveSelectionColor}"/>

    <SolidColorBrush x:Key="ComboBoxButtonNormalBackground" Color="{StaticResource LightColor}"/>

    <SolidColorBrush x:Key="ComboBoxNormalBackground" Color="{StaticResource DarkColor}"/>
    <SolidColorBrush x:Key="ComboBoxNormalBorder" Color="{StaticResource BorderColor}"/>
    
    <SolidColorBrush x:Key="ButtonNormalBackground" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="ButtonNormalBorder" Color="#4C4C4C"/>

    <SolidColorBrush x:Key="CheckedButton.Background" Color="{StaticResource LightColor}"/>
    
    <SolidColorBrush x:Key="Button.Border" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="Button.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="Button.Foreground" Color="{StaticResource ForegroundColor}"/>

    <SolidColorBrush x:Key="Button.Pressed.Background" Color="{StaticResource SecondaryColor.Pressed}"/>
    
    <SolidColorBrush x:Key="Button.MouseOver.Background" Color="{StaticResource SecondaryColor.Highlight}"/>

    <SolidColorBrush x:Key="Button.Disabled.Border" Color="{StaticResource LightColor.Disabled}"/>
    <SolidColorBrush x:Key="Button.Disabled.Background" Color="{StaticResource SecondaryColor.Disabled}"/>
    <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="{StaticResource ForegroundColor.Disabled}"/>

    <SolidColorBrush x:Key="Expander.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="Expander.MouseOver.Arrow.Stroke" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="Expander.Disabled.Arrow.Stroke" Color="{StaticResource ForegroundColor.Disabled}"/>
    <SolidColorBrush x:Key="Expander.Static.Arrow.Stroke" Color="#AAAAAA"/>

    <SolidColorBrush x:Key="SliderThumb.Static.Background" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="SliderThumb.Static.Border" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="SliderThumb.MouseOver.Background" Color="{StaticResource HighlightColor}"/>
    <SolidColorBrush x:Key="SliderThumb.MouseOver.Border" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="SliderThumb.Pressed.Background" Color="{StaticResource PressedColor}"/>
    <SolidColorBrush x:Key="SliderThumb.Pressed.Border" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="SliderThumb.Disabled.Background" Color="{StaticResource SecondaryColor.Disabled}"/>
    <SolidColorBrush x:Key="SliderThumb.Disabled.Border" Color="{StaticResource LightColor.Disabled}"/>
    <SolidColorBrush x:Key="SliderThumb.Track.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="SliderThumb.Track.Border" Color="{StaticResource DarkColor}"/>

    <SolidColorBrush x:Key="CheckBoxFillNormal" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="CheckBoxMouseOverStroke" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="CheckBoxDisabledStroke" Color="{StaticResource LightColor.Disabled}"/>
    <SolidColorBrush x:Key="CheckBoxDisabledForeground" Color="{StaticResource ForegroundColor.Disabled}"/>
    <SolidColorBrush x:Key="CheckBoxStroke" Color="{StaticResource LightColor}"/>

    <SolidColorBrush x:Key="RadioButtonMouseOverStroke" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="RadioButtonDisabledStroke" Color="{StaticResource LightColor.Disabled}"/>
    <SolidColorBrush x:Key="RadioButtonDisabledForeground" Color="{StaticResource ForegroundColor.Disabled}"/>
    <SolidColorBrush x:Key="RadioButtonStroke" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="RadioButton.Foreground" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="RadioButton.Background" Color="{StaticResource HighlightColor}"/>

    <SolidColorBrush x:Key="ListBorder" Color="{StaticResource LightColor}"/>
    <SolidColorBrush x:Key="ListBackground" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="SelectedListItem" Color="{StaticResource SelectionColor}"/>
    <SolidColorBrush x:Key="SelectedListItemForeground" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="MouseOverListItem" Color="#4A4A4A"/>

    <SolidColorBrush x:Key="TreeViewBackground" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="TreeViewDisabledForeground" Color="{StaticResource ForegroundColor.Disabled}"/>

    <SolidColorBrush x:Key="Menu.Background" Color="{StaticResource DarkColor}"/>
    <SolidColorBrush x:Key="MenuItemSelectionFill" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="MenuItemPressedFill" Color="{StaticResource HighlightColor}"/>
    <SolidColorBrush x:Key="SubMenu.Default.Background" Color="#3A3A3A"/>
    <SolidColorBrush x:Key="SubMenu.Default.Border" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="SubMenu.RepeatButton.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="SubMenu.RepeatButton.Selected.Background" Color="#7F7F7F"/>

    <SolidColorBrush x:Key="Separator.Background" Color="#4C4C4C"/>

    <SolidColorBrush x:Key="DataGrid.Background" Color="{StaticResource DarkestColor}"/>
    <SolidColorBrush x:Key="DataGrid.Border" Color="{StaticResource SecondaryColor}"/>

    <SolidColorBrush x:Key="DataGrid.Header.Background" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="DataGrid.Header.Border" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="DataGrid.Header.Highlight" Color="{StaticResource SecondaryColor.Highlight}"/>

    <SolidColorBrush x:Key="DataGrid.Column.Border" Color="Transparent"/>

    <SolidColorBrush x:Key="DataGrid.Row.Border" Color="{StaticResource SecondaryColor}"/>
    <SolidColorBrush x:Key="DataGrid.Row.Background" Color="{StaticResource DarkColor}"/>
    <SolidColorBrush x:Key="DataGrid.Row.Selected" Color="{StaticResource SelectionColor}"/>
    <SolidColorBrush x:Key="DataGrid.Row.Hover" Color="{StaticResource PrimaryColor.Highlight}"/>

    <SolidColorBrush x:Key="{x:Static DataGrid.FocusBorderBrushKey}" Color="Transparent"/>

    <Geometry x:Key="MenuScrollDownArrowGeometry">M-0.7,5.2 L-2.2,6.7 3.6,12.6 9.5,6.7 8,5.2 3.6,9.6 z</Geometry>
    <Geometry x:Key="MenuScrollUpArrowGeometry">M-2.2,10.9 L-0.7,12.4 3.7,8 8,12.4 9.5,10.9 3.7,5 z</Geometry>
    <Geometry x:Key="Checkmark">M1.0E-41,4.2 L0,2.1 2.5,4.5 6.7,4.4E-47 6.7,2.3 2.5,6.7 z</Geometry>
    <Geometry x:Key="CheckBoxCheckmark">M7.2,5 L5.5,7.16 4.16,6.3 3.5,6.7 5.5,8.4 8.6,5.25 C8.6,5.25 8,4.7 7.22,5</Geometry>
    <Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>
    <Geometry x:Key="TabItemRoundedCorner">M6.5,2.6C4.767,0.973 2.509,0 0,0 0,0 0,19 0,19L23,19z</Geometry>
    <Geometry x:Key="RepeatButton">M3.5445026,0 L7.0890052,7.0890053 L3.0459049E-09,7.0890053 z</Geometry>
    <Geometry x:Key="ComboBoxArrow">M-0,6 L-0,8 8,8 8,-0 6,-0 6,6 z</Geometry>
    <Geometry x:Key="Expander.NormalArrow">M 1,1.5 L 4.5,5 L 8,1.5</Geometry>
    <Geometry x:Key="Expander.CheckedArrow">M 1,4.5  L 4.5,1  L 8,4.5</Geometry>
    <Geometry x:Key="ExpanderToggleButtonArrow">M5,-0 L9,5 1,5 z</Geometry>

    <Geometry x:Key="SliderThumb.Horizontal.Default">M0 26 L0 6 Q0 0 3 0 Q6 0 6 6 L6 26 Q6 32 3 32 Q0 32 0 26 z</Geometry>
    <!--FontStyle-->
    <Style TargetType="{x:Type local:IconImage}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
    </Style>
    <Style TargetType="{x:Type TextElement}">
        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>
    <Style TargetType="{x:Type Paragraph}">
        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <!--<Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/> This breaks disabled text overrides -->
    </Style>
    <Style TargetType="{x:Type Control}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>
    <Style TargetType="{x:Type Window}">
        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Background" Value="{StaticResource Window.Background}"/>
    </Style>

    <Style TargetType="{x:Type Grid}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>
    </Style>


    <!-- Necessary for Blend designer for UserControls -->
    <Style TargetType="{x:Type UserControl}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>

    <Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="SliderThumbHorizontalDefault" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center" Width="8">
            <Path x:Name="grip" Data="{StaticResource SliderThumb.Horizontal.Default}" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" SnapsToDevicePixels="True" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderThumbHorizontalTop" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
            <Path x:Name="grip" Data="M 0,6 C0,6 5.5,0 5.5,0 5.5,0 11,6 11,6 11,6 11,18 11,18 11,18 0,18 0,18 0,18 0,6 0,6 z" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" SnapsToDevicePixels="True" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderThumbHorizontalBottom" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
            <Path x:Name="grip" Data="M 0,12 C0,12 5.5,18 5.5,18 5.5,18 11,12 11,12 11,12 11,0 11,0 11,0 0,0 0,0 0,0 0,12 0,12 z" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" SnapsToDevicePixels="True" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderHorizontal" TargetType="{x:Type Slider}">
        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TickBar x:Name="TopTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,0,0,2" Placement="Top" Grid.Row="0" Visibility="Collapsed"/>
                <TickBar x:Name="BottomTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,2,0,0" Placement="Bottom" Grid.Row="2" Visibility="Collapsed"/>
                <Border x:Name="TrackBackground" Background="{StaticResource SliderThumb.Track.Background}" BorderBrush="{StaticResource SliderThumb.Track.Border}" CornerRadius="2" BorderThickness="1" Height="4.0" Margin="5,0" Grid.Row="1" VerticalAlignment="center">
                    <Canvas Margin="-6,-1">
                        <Rectangle x:Name="PART_SelectionRange" Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Height="4.0" Visibility="Hidden"/>
                    </Canvas>
                </Border>
                <Track x:Name="PART_Track" Grid.Row="1">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                    </Track.DecreaseRepeatButton>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                    </Track.IncreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" Template="{StaticResource SliderThumbHorizontalDefault}" VerticalAlignment="Center" Width="11"/>
                    </Track.Thumb>
                </Track>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalTop}"/>
                <Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalBottom}"/>
                <Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsSelectionRangeEnabled" Value="true">
                <Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Foreground" TargetName="Thumb" Value="Blue"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderThumbVerticalDefault" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
            <Path x:Name="grip" Data="M0.5,0.5 L18.5,0.5 18.5,11.5 0.5,11.5z" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" Stretch="Fill"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderThumbVerticalLeft" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
            <Path x:Name="grip" Data="M 6,11 C6,11 0,5.5 0,5.5 0,5.5 6,0 6,0 6,0 18,0 18,0 18,0 18,11 18,11 18,11 6,11 6,11 z" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" Stretch="Fill"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderThumbVerticalRight" TargetType="{x:Type Thumb}">
        <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
            <Path x:Name="grip" Data="M 12,11 C12,11 18,5.5 18,5.5 18,5.5 12,0 12,0 12,0 0,0 0,0 0,0 0,11 0,11 0,11 12,11 12,11 z" Fill="{StaticResource SliderThumb.Static.Background}" Stroke="{StaticResource SliderThumb.Static.Border}" Stretch="Fill"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="SliderVertical" TargetType="{x:Type Slider}">
        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TickBar x:Name="TopTick" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4"/>
                <TickBar x:Name="BottomTick" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4"/>
                <Border x:Name="TrackBackground" Background="{StaticResource SliderThumb.Track.Background}" BorderBrush="{StaticResource SliderThumb.Track.Border}" BorderThickness="1" CornerRadius="2" Grid.Column="1" HorizontalAlignment="center" Margin="0,5" Width="4.0">
                    <Canvas Margin="-1,-6">
                        <Rectangle x:Name="PART_SelectionRange" Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Visibility="Hidden" Width="4.0"/>
                    </Canvas>
                </Border>
                <Track x:Name="PART_Track" Grid.Column="1">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                    </Track.DecreaseRepeatButton>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                    </Track.IncreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="Thumb" Focusable="False" Height="11" OverridesDefaultStyle="True" Template="{StaticResource SliderThumbVerticalDefault}" VerticalAlignment="Top" Width="18"/>
                    </Track.Thumb>
                </Track>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalLeft}"/>
                <Setter Property="Margin" TargetName="TrackBackground" Value="2,5,0,5"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalRight}"/>
                <Setter Property="Margin" TargetName="TrackBackground" Value="0,5,2,5"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsSelectionRangeEnabled" Value="true">
                <Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Foreground" TargetName="Thumb" Value="Blue"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style TargetType="{x:Type Slider}">
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template" Value="{StaticResource SliderHorizontal}"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Template" Value="{StaticResource SliderVertical}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--TabControl-->
    <Style TargetType="{x:Type TabControl}">
        <Style.Resources>
            <Style x:Key="BottomStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TransformGroup>
                            <ScaleTransform ScaleY="-1" ScaleX="1"/>
                            <SkewTransform AngleY="0" AngleX="0"/>
                            <RotateTransform Angle="0"/>
                            <TranslateTransform />
                        </TransformGroup>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="RightStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <RotateTransform Angle="90" />
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="RoundedCornerLeftStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <RotateTransform Angle="-90" />
                    </Setter.Value>
                </Setter>
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <ScaleTransform ScaleY="-1"/>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="LeftStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <RotateTransform Angle="-90" />
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="DefaultStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <RotateTransform Angle="0" />
                    </Setter.Value>
                </Setter>
            </Style>

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

            <Style TargetType="{x:Type TabItem}">
                <Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}"/>
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                <Setter Property="Background" Value="{StaticResource TabItem.Default.Background}"/>
                <Setter Property="BorderBrush" Value="{StaticResource TabItem.Default.BorderBrush}"/>
                <Setter Property="Padding" Value="5,0,5,0"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid x:Name="Container">
                                <Grid x:Name="Grid" SnapsToDevicePixels="true" UseLayoutRounding="True" Margin="1,0,-12,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Path x:Name="RoundedCorner"
                                          Grid.Column="1"
                                          Grid.Row="0"
                                          Width="24"
                                          Stretch="Fill"
                                          Margin="-2,0,0,0"
                                          Data="{StaticResource TabItemRoundedCorner}"
                                          Fill="{TemplateBinding Background}"
                                          Stroke="{TemplateBinding BorderBrush}"
                                          StrokeThickness="1"
                                          UseLayoutRounding="True"
                                          SnapsToDevicePixels="True" />
                                    <Border x:Name="Bd"
                                            Grid.Column="0"
                                            Grid.Row="0" 
                                            CornerRadius="3,0,0,0"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1,1,0,1"
                                            Background="{TemplateBinding Background}"
                                            Padding="{TemplateBinding Padding}"
                                            UseLayoutRounding="True"
                                            SnapsToDevicePixels="True">
                                        <ContentPresenter x:Name="Content" Margin="6,1,6,1" ContentSource="Header"
                                                HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
                                                RecognizesAccessKey="True"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                    </Border>
                                </Grid>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItem.Hot.Background}"/>
                                    <Setter Property="Fill"  TargetName="RoundedCorner" Value="{StaticResource TabItem.Hot.Background}"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="true">
                                    <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItem.Selected.Background}"/>
                                    <Setter Property="Fill"  TargetName="RoundedCorner" Value="{StaticResource TabItem.Selected.Background}"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter Property="Panel.ZIndex" Value="-1"/>
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="false"/>
                                        <Condition Property="IsMouseOver" Value="true"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TabItem.Hot.BorderBrush}"/>
                                    <Setter Property="Stroke" TargetName="RoundedCorner" Value="{StaticResource TabItem.Hot.BorderBrush}"/>
                                </MultiTrigger>
                                <Trigger Property="TabStripPlacement" Value="Bottom">
                                    <Setter Property="Style" TargetName="RoundedCorner" Value="{StaticResource BottomStyle}"/>
                                    <Setter Property="Style" TargetName="Bd" Value="{StaticResource BottomStyle}"/>
                                    <Setter Property="Style" TargetName="Content" Value="{StaticResource BottomStyle}"/>
                                </Trigger>
                                <Trigger Property="TabStripPlacement" Value="Left">
                                    <Setter Property="Grid.Row" TargetName="Bd" Value="0"/>
                                    <Setter Property="Grid.Column" TargetName="Bd" Value="0"/>
                                    <Setter Property="Grid.Row" TargetName="RoundedCorner" Value="1"/>
                                    <Setter Property="Grid.Column" TargetName="RoundedCorner" Value="0"/>
                                    <Setter Property="Style" TargetName="RoundedCorner" Value="{StaticResource RoundedCornerLeftStyle}"/>
                                    <Setter Property="Style" TargetName="Bd" Value="{StaticResource LeftStyle}"/>
                                    <Setter Property="Style" TargetName="Content" Value="{StaticResource DefaultStyle}"/>
                                    <Setter Property="Margin" TargetName="Grid" Value="0,1,0,-16"/>
                                    <Setter Property="CornerRadius" TargetName="Bd" Value="0 3 0 0"/>
                                    <Setter Property="Margin" TargetName="RoundedCorner" Value="0 4 0 0"/>
                                </Trigger>
                                <Trigger Property="TabStripPlacement" Value="Right">
                                    <Setter Property="Grid.Row" TargetName="Bd" Value="0"/>
                                    <Setter Property="Grid.Column" TargetName="Bd" Value="1"/>
                                    <Setter Property="Grid.Row" TargetName="RoundedCorner" Value="1"/>
                                    <Setter Property="Grid.Column" TargetName="RoundedCorner" Value="1"/>
                                    <Setter Property="Style" TargetName="RoundedCorner" Value="{StaticResource RightStyle}"/>
                                    <Setter Property="Style" TargetName="Bd" Value="{StaticResource RightStyle}"/>
                                    <Setter Property="Style" TargetName="Content" Value="{StaticResource DefaultStyle}"/>
                                    <Setter Property="Margin" TargetName="Grid" Value="0,1,0,-12"/>
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="TabStripPlacement" Value="Top"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Margin"  Value="0,0,0,-1"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="TabStripPlacement" Value="Bottom"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Margin" Value="0,-1,0,0"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="TabStripPlacement" Value="Left"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Margin" Value="0,0,-1,0"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="TabStripPlacement" Value="Right"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Margin" Value="-1,0,0,0"/>
                                </MultiTrigger>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItem.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TabItem.Disabled.BorderBrush}"/>
                                    <Setter Property="Fill" TargetName="RoundedCorner" Value="{StaticResource TabItem.Disabled.Background}"></Setter>
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type local:WindowItem}" BasedOn="{StaticResource {x:Type TabItem}}" />
        </Style.Resources>

        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Selected.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Default.BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>

    <!-- ScrollBar -->
    <Style TargetType="{x:Type ScrollViewer}">
        <Setter Property="Background" Value="{DynamicResource ScrollViewer.Background}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Rectangle x:Name="Corner"
                            Grid.Column="1"
                            Grid.Row="1"
                            Fill="{TemplateBinding Background}"/>
                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                            CanContentScroll="{TemplateBinding CanContentScroll}"
                            CanHorizontallyScroll="False"
                            CanVerticallyScroll="False"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Content="{TemplateBinding Content}"
                            Grid.Column="0"
                            Grid.Row="0"
                            Margin="{TemplateBinding Padding}"/>
                        <ScrollBar x:Name="PART_VerticalScrollBar"
                            AutomationProperties.AutomationId="VerticalScrollBar"
                            Cursor="Arrow"
                            Grid.Column="1"
                            Grid.Row="0"
                            Maximum="{TemplateBinding ScrollableHeight}"
                            Minimum="0" 
                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                            Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                            ViewportSize="{TemplateBinding ViewportHeight}"
                            Style="{DynamicResource VerticalScrollBarStyle}"/>
                        <ScrollBar x:Name="PART_HorizontalScrollBar"
                            AutomationProperties.AutomationId="HorizontalScrollBar"
                            Cursor="Arrow"
                            Grid.Column="0" 
                            Grid.Row="1"
                            Maximum="{TemplateBinding ScrollableWidth}"
                            Minimum="0"
                            Orientation="Horizontal"
                            Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                            Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                            ViewportSize="{TemplateBinding ViewportWidth}"
                            Style="{DynamicResource HorisontalScrollBarStyle}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RepeatButtonUpStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Background="Transparent">
                        <Path x:Name="TrianglePath" Data="{StaticResource RepeatButton}" 
                                    Fill="{StaticResource ScrollBar.Thumb.Background}" Height="Auto" Margin="5" Stretch="Fill" Width="Auto"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsPressed"  Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid>
                        <Rectangle x:Name="VerticalThumb" Fill="{StaticResource ScrollBar.Thumb.Background}"
                                    Width="7.4" RadiusX="4" RadiusY="4"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="VerticalThumb" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsDragging"  Value="True">
                            <Setter Property="Fill" TargetName="VerticalThumb" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RepeatButtonDownStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource RepeatButtonUpStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Background="Transparent">
                        <Path x:Name="BottomTrianglePath" Data="{StaticResource RepeatButton}" 
                                    Fill="{StaticResource ScrollBar.Thumb.Background}" Height="Auto" Margin="5" Stretch="Fill" Width="Auto"
                                    RenderTransformOrigin="0.5,0.5">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleY="-1" ScaleX="1"/>
                                    <SkewTransform AngleY="0" AngleX="0"/>
                                    <RotateTransform Angle="0"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="BottomTrianglePath" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsPressed"  Value="True">
                            <Setter Property="Fill" TargetName="BottomTrianglePath" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}"
                                Height="{TemplateBinding Height}"
                                Width="{TemplateBinding Width}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="VerticalScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="{StaticResource ScrollBar.Default.Background}"/>
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                            <RowDefinition Height="0.00001*"/>
                            <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                        </Grid.RowDefinitions>
                        <RepeatButton Command="{x:Static ScrollBar.LineUpCommand}"
                                    IsEnabled="{TemplateBinding IsMouseOver}"
                                    Style="{StaticResource RepeatButtonUpStyle}"/>
                        <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                            </Track.DecreaseRepeatButton>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                            </Track.IncreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Style="{StaticResource ScrollBarThumb}"/>
                            </Track.Thumb>
                        </Track>
                        <RepeatButton Command="{x:Static ScrollBar.LineDownCommand}"
                                    IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="2" 
                                    Style="{DynamicResource RepeatButtonDownStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBar.Disabled.Background}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="MinWidth" Value="0"/>
                <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="Background" Value="{StaticResource ScrollBar.Default.Background}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                    <ColumnDefinition Width="0.00001*"/>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                </Grid.ColumnDefinitions>
                                <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource RepeatButtonUpStyle}"/>
                                <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                    </Track.Thumb>
                                </Track>
                                <RepeatButton Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource RepeatButtonUpStyle}"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBar.Disabled.Background}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="HorisontalScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="{StaticResource ScrollBar.Default.Background}"/>
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="MinWidth" Value="0"/>
                <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="Background" Value="{StaticResource ScrollBar.Default.Background}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid x:Name="Bg" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                    <ColumnDefinition Width="0.00001*"/>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                </Grid.ColumnDefinitions>
                                <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{DynamicResource RepeatLeftButtonStyle}"/>
                                <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb Style="{DynamicResource HorisontalThumbStyle}"/>
                                    </Track.Thumb>
                                </Track>
                                <RepeatButton Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{DynamicResource RepeatRightButtonStyle}"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBar.Disabled.Background}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="HorisontalThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid>
                        <Rectangle x:Name="VerticalThumb" Fill="{StaticResource ScrollBar.Thumb.Background}"
                                    Height="7.4" RadiusX="4" RadiusY="4"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="VerticalThumb" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsDragging"  Value="True">
                            <Setter Property="Fill" TargetName="VerticalThumb" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RepeatLeftButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Background="Transparent" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform Angle="270"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Path x:Name="TrianglePath" Data="{StaticResource RepeatButton}" 
                                    Fill="{StaticResource ScrollBar.Thumb.Background}" Height="Auto" Margin="5" Stretch="Fill" Width="Auto"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsPressed"  Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RepeatRightButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Background="Transparent" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform Angle="270"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Path x:Name="TrianglePath" Data="{StaticResource RepeatButton}" 
                                    Fill="{StaticResource ScrollBar.Thumb.Background}" Height="Auto" Margin="5" Stretch="Fill" Width="Auto" RenderTransformOrigin="0.5,0.5">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform Angle="180"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Hot}"/>
                        </Trigger>
                        <Trigger Property="IsPressed"  Value="True">
                            <Setter Property="Fill" TargetName="TrianglePath" Value="{StaticResource ScrollBar.Thumb.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Tooltip -->
    <Style TargetType="ToolTip">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Border Name="Border" BorderThickness="1" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStopCollection>
                                        <GradientStop Color="{DynamicResource LightColor}" Offset="0.0" />
                                        <GradientStop Color="{DynamicResource SecondaryColor}" Offset="1.0" />
                                    </GradientStopCollection>
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </Border.Background>

                        <Border.BorderBrush>
                            <SolidColorBrush Color="{DynamicResource SecondaryColor}" />
                        </Border.BorderBrush>

                        <ContentPresenter Margin="4" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="true">
                            <Setter TargetName="Border" Property="CornerRadius" Value="4" />
                            <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TextBox -->
    <Style TargetType="{x:Type RichTextBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource TextBox.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TextBox.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="2,2,2,1"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
    </Style>

    <Style BasedOn="{StaticResource {x:Type Control}}" TargetType="{x:Type TextBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource TextBox.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TextBox.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="2,2,2,1"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border x:Name="Bd"
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        Background="{TemplateBinding Background}"
                        CornerRadius="3"
                        SnapsToDevicePixels="true">
                        <ScrollViewer x:Name="PART_ContentHost" Padding="{TemplateBinding Padding}" 
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource TextBox.Disabled.Foreground}"/>
                            <Setter Property="Background" TargetName="PART_ContentHost" Value="{StaticResource TextBox.Disabled.Background}"/>
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource TextBox.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TextBox.Disabled.Background}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <!--<MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
                    <Condition Property="IsSelectionActive" Value="false"/>
                </MultiTrigger.Conditions>
                <Setter Property="SelectionBrush" Value="{StaticResource InactiveSelectionHighlightBrush}"/>
            </MultiTrigger>-->
        </Style.Triggers>
    </Style>

    <!-- ComboBox -->
    <Style x:Key="ComboBoxFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2,2,21,2" SnapsToDevicePixels="true"
                        Stroke="{StaticResource ForegroundBrush}"
                        StrokeThickness="1"
                        StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="ComboBoxReadonlyToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="ClickMode" Value="Press"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border  
                        CornerRadius="3"             
                        BorderBrush="{StaticResource ComboBoxNormalBorder}" 
                        BorderThickness="1"
                        Background="{TemplateBinding Background}" 
                        SnapsToDevicePixels="true">
                        <Border x:Name="PopUpButton"
                            HorizontalAlignment="Right"
                            Background="{DynamicResource ComboBoxButtonNormalBackground}"
                            CornerRadius="3"
                            Margin="1"
                            Width="15">
                            <Path x:Name="Arrow" Data="{StaticResource ComboBoxArrow}" 
                                HorizontalAlignment="Center" 
                                VerticalAlignment="Center"
                                Width="5.5"
                                Height="5.5" 
                                Stretch="Fill" 
                                Fill="{DynamicResource Button.Foreground}"
                                RenderTransformOrigin="0.5,0.5" 
                                Margin="0,4,0,7">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform Angle="45"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" TargetName="PopUpButton" Value="{DynamicResource Button.MouseOver.Background}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource Button.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DownArrowToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="ClickMode" Value="Press"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border  
                        CornerRadius="3"             
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        Background="{TemplateBinding Background}" 
                        SnapsToDevicePixels="true">
                        <Border x:Name="PopUpButton"
                            HorizontalAlignment="Right"
                            CornerRadius="3"
                            Margin="1"
                            Width="15">
                            <Path x:Name="Arrow" Data="{StaticResource ComboBoxArrow}" 
                                HorizontalAlignment="Center" 
                                VerticalAlignment="Center"
                                Width="5.5"
                                Height="5.5" 
                                Stretch="Fill" 
                                Fill="{DynamicResource Button.Foreground}"
                                RenderTransformOrigin="0.5,0.5" 
                                Margin="0,4,0,7">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform Angle="45"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource Button.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
        <Grid x:Name="Placement" SnapsToDevicePixels="true">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup"
                AllowsTransparency="true" 
                Grid.ColumnSpan="2"
                IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" 
                Margin="1" 
                PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" 
                Placement="Bottom">
                <Border x:Name="Shdw"
                    Background="Transparent" 
                    MaxHeight="{TemplateBinding MaxDropDownHeight}" 
                    MinWidth="{Binding ActualWidth, ElementName=Placement}">
                    <Border x:Name="DropDownBorder" 
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="1" 
                        Background="{TemplateBinding Background}">
                        <ScrollViewer x:Name="DropDownScrollViewer">
                            <Grid RenderOptions.ClearTypeHint="Enabled">
                                <Canvas HorizontalAlignment="Left" 
                                    Height="0" 
                                    VerticalAlignment="Top" 
                                    Width="0">
                                    <Rectangle x:Name="OpaqueRect" 
                                        Fill="{Binding Background, ElementName=DropDownBorder}" 
                                        Height="{Binding ActualHeight, ElementName=DropDownBorder}" 
                                        Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
                                </Canvas>
                                <ItemsPresenter x:Name="ItemsPresenter"
                                    KeyboardNavigation.DirectionalNavigation="Contained" 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Grid>
                        </ScrollViewer>
                    </Border>
                </Border>
            </Popup>
            <Border x:Name="Border" 
                BorderBrush="{TemplateBinding BorderBrush}" 
                BorderThickness="{TemplateBinding BorderThickness}" 
                Background="{TemplateBinding Background}" 
                CornerRadius="3"
                Grid.ColumnSpan="2"/>
            <TextBox x:Name="PART_EditableTextBox" />
            <ToggleButton Grid.Column="1" 
                IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                Style="{StaticResource ComboBoxReadonlyToggleButton}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="false">
                <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource TextBox.Disabled.Foreground}"/>
                <Setter Property="Background" Value="{DynamicResource TextBox.Disabled.Background}"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="true"/>
                    <!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
                </MultiTrigger.Conditions>
                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
            </MultiTrigger>
            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                <Setter Property="Background" TargetName="Shdw" Value="#71000000"/>
            </Trigger>
            <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
                <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
                <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
        <Setter Property="Foreground" Value="{DynamicResource Button.Foreground}"/>
        <Setter Property="Background" Value="{StaticResource ComboBoxNormalBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
        <Setter Property="Padding" Value="5,3,5,1"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="ItemContainerStyle" Value="{DynamicResource ComboBoxItemStyle}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid x:Name="MainGrid" SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition MinWidth="18" Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Popup x:Name="PART_Popup" 
                            AllowsTransparency="true" 
                            Grid.ColumnSpan="2"
                            IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" 
                            Margin="1" 
                            PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" 
                            Placement="Bottom">
                            <Border x:Name="Shdw" 
                                Background="Transparent" 
                                MaxHeight="{TemplateBinding MaxDropDownHeight}" 
                                MinWidth="{Binding ActualWidth, ElementName=MainGrid}">
                                <Border x:Name="DropDownBorder" 
                                    BorderBrush="{TemplateBinding BorderBrush}" 
                                    BorderThickness="1" 
                                    Background="{TemplateBinding Background}">
                                    <ScrollViewer x:Name="DropDownScrollViewer" 
                                        >
                                        <Grid RenderOptions.ClearTypeHint="Enabled">
                                            <Canvas HorizontalAlignment="Left" 
                                                Height="0" 
                                                VerticalAlignment="Top" 
                                                Width="0">
                                                <Rectangle x:Name="OpaqueRect" 
                                                    Fill="{Binding Background, ElementName=DropDownBorder}" 
                                                    Height="{Binding ActualHeight, ElementName=DropDownBorder}" 
                                                    Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
                                            </Canvas>
                                            <ItemsPresenter x:Name="ItemsPresenter" 
                                                KeyboardNavigation.DirectionalNavigation="Contained" 
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </Grid>
                                    </ScrollViewer>
                                </Border>
                            </Border>
                        </Popup>
                        <ToggleButton
                            Background="{TemplateBinding Background}" 
                            Grid.ColumnSpan="2" 
                            IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                            Style="{StaticResource ComboBoxReadonlyToggleButton}"/>
                        <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" 
                            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                            Content="{TemplateBinding SelectionBoxItem}" 
                            ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" 
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                            IsHitTestVisible="false" 
                            Margin="{TemplateBinding Padding}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                            <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                            <Setter Property="Background" TargetName="Shdw" Value="#71000000"/>
                        </Trigger>
                        <Trigger Property="HasItems" Value="false">
                            <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource TextBox.Disabled.Foreground}"/>
                            <Setter Property="Background" Value="{DynamicResource TextBox.Disabled.Background}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="true"/>
                                <!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </MultiTrigger>
                        <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
                            <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
                            <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEditable" Value="true">
                <!--<Setter Property="BorderBrush" Value="{StaticResource TextBox.Border2}"/>
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>-->
                <Setter Property="IsTabStop" Value="false"/>
                <Setter Property="Padding" Value="3"/>
                <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}">
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="3,0,3,0"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource SelectedListItem}"/>
                            <Setter Property="Foreground" Value="Black"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Button-->
    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true"
                        Stroke="{StaticResource ForegroundBrush}"
                        StrokeThickness="1"
                        StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>
        
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource Button.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource Button.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{StaticResource Button.Foreground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="Border"
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}"
                            TextBlock.Foreground="{TemplateBinding Foreground}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3">

                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="{TemplateBinding Padding}" 
                            RecognizesAccessKey="True" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="{StaticResource Button.MouseOver.Background}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" Value="{StaticResource Button.Pressed.Background}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}"/>
                            <Setter Property="Foreground" Value="{StaticResource Button.Disabled.Foreground}"/>
                            <Setter Property="Background" Value="{StaticResource Button.Disabled.Background}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ToggleButton-->
    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource Button.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource Button.Border}"/>
        <Setter Property="BorderThickness" Value="1"></Setter>
        <Setter Property="Foreground" Value="{StaticResource Button.Foreground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border  
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        Background="{TemplateBinding Background}" 
                        BorderThickness="{TemplateBinding BorderThickness}"
                        SnapsToDevicePixels="true"
                        CornerRadius="3">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          Margin="{TemplateBinding Padding}" 
                                          RecognizesAccessKey="True" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsChecked" Value="false"/>
                                <Condition Property="IsMouseOver" Value="true"/>
                            </MultiTrigger.Conditions>
                        </MultiTrigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="{StaticResource Button.MouseOver.Background}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource Button.Disabled.Foreground}"/>
                            <Setter Property="Background" Value="{StaticResource Button.Disabled.Background}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Background" Value="{StaticResource CheckedButton.Background}"/>
                            <Setter Property="Foreground" Value="{StaticResource Button.Foreground}"/>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Expander -->


    <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="19"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid>
                                <Grid.LayoutTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <TransformCollection>
                                                <RotateTransform Angle="-90"/>
                                            </TransformCollection>
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Grid.LayoutTransform>
                                <Path x:Name="arrow" Data="{StaticResource Expander.NormalArrow}" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/>
                            </Grid>
                            <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="{StaticResource Expander.CheckedArrow}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="19"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid>
                                <Grid.LayoutTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <TransformCollection>
                                                <RotateTransform Angle="180"/>
                                            </TransformCollection>
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Grid.LayoutTransform>
                                <Path x:Name="arrow" Data="{StaticResource Expander.NormalArrow}" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/>
                            </Grid>
                            <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="{StaticResource Expander.CheckedArrow}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="19"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid>
                                <Grid.LayoutTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <TransformCollection>
                                                <RotateTransform Angle="90"/>
                                            </TransformCollection>
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Grid.LayoutTransform>
                                <Path x:Name="arrow" Data="{StaticResource Expander.NormalArrow}" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/>
                            </Grid>
                            <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="{StaticResource Expander.CheckedArrow}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderHeaderFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="19"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="arrow" Data="{StaticResource Expander.NormalArrow}" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="{StaticResource Expander.Static.Arrow.Stroke}" StrokeThickness="2" VerticalAlignment="Center"/>
                            <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="{StaticResource Expander.CheckedArrow}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Expander}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Foreground" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
        <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="Background" Value="{StaticResource Expander.Background}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        Background="{TemplateBinding Background}" 
                        CornerRadius="4" 
                        SnapsToDevicePixels="true">
                        <DockPanel>
                            <ToggleButton x:Name="HeaderSite" 
                                ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" 
                                Content="{TemplateBinding Header}" 
                                DockPanel.Dock="Top" 
                                Foreground="{TemplateBinding Foreground}" 
                                FontWeight="{TemplateBinding FontWeight}" 
                                FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" 
                                FontStyle="{TemplateBinding FontStyle}" 
                                FontStretch="{TemplateBinding FontStretch}" 
                                FontSize="{TemplateBinding FontSize}" 
                                FontFamily="{TemplateBinding FontFamily}" 
                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                Margin="5,1,1,1" 
                                MinWidth="0" 
                                MinHeight="0" 
                                Padding="{TemplateBinding Padding}" 
                                Style="{DynamicResource ExpanderToggleButtonStyle}" 
                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <ContentPresenter x:Name="ExpandSite" 
                                DockPanel.Dock="Bottom"
                                Focusable="false" 
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                Margin="{TemplateBinding Padding}" 
                                Visibility="Collapsed" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Up">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Left">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="8"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="arrow"
                                Grid.ColumnSpan="2" 
                                HorizontalAlignment="Left" 
                                Fill="{StaticResource Expander.Static.Arrow.Stroke}" 
                                Stroke="{StaticResource Expander.Static.Arrow.Stroke}" 
                                StrokeThickness="1" 
                                VerticalAlignment="Top" 
                                Data="{StaticResource ExpanderToggleButtonArrow}" 
                                Height="4.5" 
                                Stretch="Fill" 
                                Width="8" 
                                RenderTransformOrigin="0.5,0.5" 
                                Margin="2.068,6.27,0,0">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <RotateTransform Angle="135"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                            <ContentPresenter Grid.Column="1" 
                                HorizontalAlignment="Left" 
                                Margin="4,0,0,0" 
                                RecognizesAccessKey="True" 
                                SnapsToDevicePixels="True" 
                                VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter Property="Margin" TargetName="arrow" Value="-0.526,4.842,0,0"></Setter>
                            <Setter Property="RenderTransform" TargetName="arrow">
                                <Setter.Value>
                                    <TransformGroup>
                                        <RotateTransform Angle="90"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CheckBox-->


    <Style x:Key="EmptyCheckBoxFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="1" 
                                    SnapsToDevicePixels="true" 
                                    Stroke="{StaticResource CheckBoxStroke}" 
                                    StrokeThickness="1" 
                                    StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="CheckRadioFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="14,0,0,0"
                                    SnapsToDevicePixels="true" 
                                    Stroke="{StaticResource CheckBoxStroke}" 
                                    StrokeThickness="1" 
                                    StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"></Setter>
        <Setter Property="Background" Value="{StaticResource CheckBoxFillNormal}"/>
        <Setter Property="BorderBrush" Value="{StaticResource CheckBoxStroke}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource EmptyCheckBoxFocusVisual}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <BulletDecorator Background="Transparent" SnapsToDevicePixels="true">
                        <BulletDecorator.Bullet>
                            <Border x:Name="CheckBoxBorder"
                                        Height="12"
                                        Width="12"
                                        BorderBrush="{TemplateBinding BorderBrush}" 
                                        BorderThickness="1"
                                        Background="{TemplateBinding Background}">
                                <Path x:Name="CheckMark"  
                                            Data="{StaticResource CheckBoxCheckmark}" 
                                            Height="Auto" 
                                            Width="Auto" 
                                            Stretch="Fill" 
                                            Fill="{StaticResource Button.Foreground}"
                                            Margin="1,1.007,1,1"/>
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                Margin="{TemplateBinding Padding}" 
                                                RecognizesAccessKey="True" 
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasContent" Value="true">
                            <Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/>
                            <Setter Property="Padding" Value="4,0,0,0"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource CheckBoxDisabledForeground}"/>
                            <Setter Property="BorderBrush" TargetName="CheckBoxBorder" Value="{StaticResource CheckBoxDisabledStroke}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" TargetName="CheckBoxBorder" Value="{StaticResource CheckBoxMouseOverStroke}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RadioButton -->


    <Style x:Key="RadioFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="14,0,0,0" 
                                    SnapsToDevicePixels="true" 
                                    Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" 
                                    StrokeThickness="1" 
                                    StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type RadioButton}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Foreground" Value="{StaticResource RadioButton.Foreground}"/>
        <Setter Property="Background" Value="{StaticResource RadioButton.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource RadioButtonStroke}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Border x:Name="RadioButtonBorder"
                                        Width="12"
                                        Height="12"
                                        CornerRadius="6" 
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        BorderBrush="{TemplateBinding BorderBrush}" 
                                        Background="{TemplateBinding Background}">
                                <Border x:Name="RadioMark" 
                                            Width="6"
                                            Height="6"
                                            CornerRadius="6"
                                            BorderBrush="{StaticResource RadioButton.Foreground}" 
                                            Background="{StaticResource RadioButton.Foreground}"/>
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                Margin="{TemplateBinding Padding}" 
                                                RecognizesAccessKey="True" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasContent" Value="true">
                            <Setter Property="FocusVisualStyle" Value="{StaticResource RadioFocusVisual}"/>
                            <Setter Property="Padding" Value="4,0,0,0"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource RadioButtonDisabledForeground}"/>
                            <Setter Property="BorderBrush" TargetName="RadioButtonBorder" Value="{StaticResource RadioButtonDisabledStroke}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" TargetName="RadioButtonBorder" Value="{StaticResource RadioButtonMouseOverStroke}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter TargetName="RadioMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ListView -->
    <Style TargetType="{x:Type ListView}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource ListBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListView}">
                    <Border x:Name="Bd"
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                Padding="1" 
                                SnapsToDevicePixels="true">
                        <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="true"/>
                                <!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="2,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                Padding="{TemplateBinding Padding}" 
                                SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource SelectedListItem}"/>
                            <Setter Property="Foreground" Value="{StaticResource SelectedListItemForeground}"/>
                        </Trigger>
                        <!--<MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
                            </MultiTrigger>-->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsSelected" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource MouseOverListItem}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Label -->
    <Style TargetType="{x:Type Label}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Label}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" 
                            Padding="{TemplateBinding Padding}" 
                            SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          RecognizesAccessKey="True" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource Button.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TreeView -->
    <Style TargetType="{x:Type TreeView}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource TreeViewBackground}"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeView}">
                    <Border x:Name="Bd" SnapsToDevicePixels="true">
                        <ScrollViewer x:Name="_tv_scrollviewer_" 
                                          Background="{TemplateBinding Background}"
                                          CanContentScroll="false" Focusable="false" 
                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                                          Padding="{TemplateBinding Padding}" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource TreeViewDisabledForeground}"/>
                        </Trigger>
                        <!--<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                                <Setter Property="CanContentScroll" TargetName="_tv_scrollviewer_" Value="true"/>
                            </Trigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Style.Triggers>
            <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>-->
    </Style>
    <Style TargetType="{x:Type local:MultiSelectTreeView}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource TreeViewBackground}"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MultiSelectTreeView}">
                    <Border x:Name="Bd" SnapsToDevicePixels="true">
                        <ScrollViewer x:Name="_tv_scrollviewer_" 
                                          Background="{TemplateBinding Background}"
                                          CanContentScroll="false" Focusable="false" 
                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                                          Padding="{TemplateBinding Padding}" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource TreeViewDisabledForeground}"/>
                        </Trigger>
                        <!--<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                                <Setter Property="CanContentScroll" TargetName="_tv_scrollviewer_" Value="true"/>
                            </Trigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Style.Triggers>
            <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>-->
    </Style>

    <Style x:Key="TreeViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type TreeViewItem}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="MinHeight" Value="24"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="2,4,2,3"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="FontWeight" Value="Normal" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <ControlTemplate.Resources>
                        <darkBlendTheme:LeftMarginMultiplierConverter Length="15" x:Key="LengthConverter" />
                    </ControlTemplate.Resources>
                    <StackPanel>
                        <Border Name="Bd"
                                      Background="{TemplateBinding Background}"
                                      Padding="{TemplateBinding Padding}">
                            <Grid Margin="{Binding Converter={StaticResource LengthConverter},
                                         RelativeSource={RelativeSource TemplatedParent}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="15"/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <ToggleButton x:Name="Expander" 
                                              Grid.Column="0"
                                              Style="{DynamicResource TreeViewToggleButtonStyle}"
                                              IsChecked="{Binding Path=IsExpanded,
                                    RelativeSource={RelativeSource TemplatedParent}}"
                                              ClickMode="Press"/>

                                <ContentPresenter x:Name="PART_Header" 
                                                  Grid.Column="1"
                                                  ContentSource="Header"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                            </Grid>
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost"/>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="false">
                            <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader" Value="false"/>
                                <Condition Property="Width" Value="Auto"/>
                            </MultiTrigger.Conditions>

                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader" Value="false"/>
                                <Condition Property="Height" Value="Auto"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Header" Property="MinHeight" Value="21"/>
                        </MultiTrigger>

                        <!--Trigger Property="IsSelected" Value="true"-->
                        <Trigger Property="local:MultiSelectTreeView.IsItemSelected" Value="true">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource SelectedListItem}"/>
                            <Setter Property="Foreground" Value="{StaticResource SelectedListItemForeground}"/>
                            <Setter Property="Style" TargetName="Expander" Value="{DynamicResource TreeViewSelectedToggleButtonStyle}"/>
                            <Setter Property="FontWeight" Value="Bold" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="Bd" Value="true"/>
                                <Condition Property="local:MultiSelectTreeView.IsItemSelected" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource MouseOverListItem}"/>
                        </MultiTrigger>
                        <!--<MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="local:MultiSelectTreeView.IsItemSelected" Value="true"/>
                                <Condition Property="IsSelectionActive" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                        </MultiTrigger>-->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource TreeViewDisabledForeground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TreeViewToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="8"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="arrow"
                                Grid.ColumnSpan="2" 
                                HorizontalAlignment="Left" 
                                Fill="{StaticResource Expander.Static.Arrow.Stroke}" 
                                Stroke="{StaticResource Expander.Static.Arrow.Stroke}" 
                                StrokeThickness="1" 
                                VerticalAlignment="Top" 
                                Data="{StaticResource ExpanderToggleButtonArrow}" 
                                Height="4.5" 
                                Stretch="Fill" 
                                Width="8" 
                                RenderTransformOrigin="0.5,0.5" 
                                Margin="2.068,6.27,0,0">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <RotateTransform Angle="135"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                            <ContentPresenter Grid.Column="1" 
                                HorizontalAlignment="Left" 
                                Margin="4,0,0,0" 
                                RecognizesAccessKey="True" 
                                SnapsToDevicePixels="True" 
                                VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter Property="Margin" TargetName="arrow" Value="-0.526,4.842,0,0"></Setter>
                            <Setter Property="RenderTransform" TargetName="arrow">
                                <Setter.Value>
                                    <TransformGroup>
                                        <RotateTransform Angle="90"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Stroke" TargetName="arrow" Value="{StaticResource Expander.Disabled.Arrow.Stroke}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="TreeViewSelectedToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="8"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="arrow"
                                Grid.ColumnSpan="2" 
                                HorizontalAlignment="Left" 
                                Fill="{StaticResource TreeViewBackground}" 
                                Stroke="{StaticResource TreeViewBackground}" 
                                StrokeThickness="1" 
                                VerticalAlignment="Top" 
                                Data="{StaticResource ExpanderToggleButtonArrow}" 
                                Height="4.5" 
                                Stretch="Fill" 
                                Width="8" 
                                RenderTransformOrigin="0.5,0.5" 
                                Margin="2.068,6.27,0,0">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <RotateTransform Angle="135"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                            <ContentPresenter Grid.Column="1" 
                                HorizontalAlignment="Left" 
                                Margin="4,0,0,0" 
                                RecognizesAccessKey="True" 
                                SnapsToDevicePixels="True" 
                                VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter Property="Margin" TargetName="arrow" Value="-0.526,4.842,0,0"></Setter>
                            <Setter Property="RenderTransform" TargetName="arrow">
                                <Setter.Value>
                                    <TransformGroup>
                                        <RotateTransform Angle="90"/>
                                        <TranslateTransform X="0.17819090885901012" Y="0.43019090885900946"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="Transparent"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsChecked" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource TreeViewBackground}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- StatusBar -->
    <Style TargetType="{x:Type StatusBar}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Margin" Value="1 0 3 0"/>
        <Setter Property="Height" Value="18"/>
        <Setter Property="Background" Value="{StaticResource Window.Background}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.StatusFontFamilyKey}}"/>
        <Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.StatusFontSizeKey}}"/>
        <Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.StatusFontStyleKey}}"/>
        <Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.StatusFontWeightKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type StatusBar}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type StatusBarItem}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Margin" Value="4 0 4 0"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type StatusBarItem}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource TextBox.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- Menu -->

    <Style TargetType="{x:Type Menu}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource Menu.Background}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" 
                            Padding="{TemplateBinding Padding}" 
                            SnapsToDevicePixels="true">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource Menu.Background}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border BorderBrush="{StaticResource SubMenu.Default.Border}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{StaticResource SubMenu.Default.Background}" 
                            Padding="{TemplateBinding Padding}" 
                            SnapsToDevicePixels="true">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MenuScrollButton" BasedOn="{x:Null}" TargetType="{x:Type RepeatButton}">
        <Setter Property="ClickMode" Value="Hover"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <DockPanel x:Name="DPButton" Background="{StaticResource SubMenu.RepeatButton.Background}" SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="ContentContainer" HorizontalAlignment="Center" Margin="2,0,2,5" VerticalAlignment="Center"/>
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" TargetName="DPButton" Value="{StaticResource SubMenu.RepeatButton.Selected.Background}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter"/>
    <Style x:Key="{ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}" BasedOn="{x:Null}" TargetType="{x:Type ScrollViewer}">
        <Setter Property="HorizontalScrollBarVisibility" Value="Hidden"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Border Grid.Column="0" Grid.Row="1">
                            <ScrollContentPresenter CanContentScroll="{TemplateBinding CanContentScroll}" Margin="{TemplateBinding Padding}"/>
                        </Border>
                        <RepeatButton Grid.Column="0" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Command="{x:Static ScrollBar.LineUpCommand}" Focusable="false" Grid.Row="0" Style="{StaticResource MenuScrollButton}">
                            <RepeatButton.Visibility>
                                <MultiBinding ConverterParameter="0" Converter="{StaticResource MenuScrollingVisibilityConverter}" FallbackValue="Visibility.Collapsed">
                                    <Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
                                </MultiBinding>
                            </RepeatButton.Visibility>
                            <Path x:Name="UpArrow" Data="{StaticResource MenuScrollUpArrowGeometry}" Fill="{StaticResource ForegroundBrush}"/>
                        </RepeatButton>
                        <RepeatButton Grid.Column="0" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Command="{x:Static ScrollBar.LineDownCommand}" Focusable="false" Grid.Row="2" Style="{StaticResource MenuScrollButton}">
                            <RepeatButton.Visibility>
                                <MultiBinding ConverterParameter="100" Converter="{StaticResource MenuScrollingVisibilityConverter}" FallbackValue="Visibility.Collapsed">
                                    <Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
                                    <Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
                                </MultiBinding>
                            </RepeatButton.Visibility>
                            <Path x:Name="DownArrow" Data="{StaticResource MenuScrollDownArrowGeometry}" Fill="{StaticResource ForegroundBrush}"/>
                        </RepeatButton>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle x:Name="Bg" 
                            Fill="{TemplateBinding Background}" 
                            Margin="1"/>
            <DockPanel>
                <ContentPresenter x:Name="Icon" 
                                        ContentSource="Icon"
                                        Margin="4,0,6,0" 
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                        VerticalAlignment="Center"/>
                <Path x:Name="GlyphPanel" 
                            Data="{StaticResource Checkmark}" 
                            Fill="{TemplateBinding Foreground}" 
                            FlowDirection="LeftToRight" 
                            Visibility="Collapsed"
                            Margin="5,0,0,0"
                            VerticalAlignment="Center" 
                            Height="7.5"
                            Stretch="Fill" 
                            Width="7.5"/>
                <ContentPresenter x:Name="Content" ContentSource="Header" 
                                        Margin="{TemplateBinding Padding}" 
                                        RecognizesAccessKey="True" 
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </DockPanel>
            <Popup x:Name="PART_Popup"
                        AllowsTransparency="true" 
                        Focusable="false" 
                        HorizontalOffset="1" 
                        IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
                        PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" 
                        Placement="Bottom" 
                        VerticalOffset="-1">
                <Border x:Name="Shdw" Background="Transparent">
                    <Border x:Name="SubMenuBorder" 
                                BorderBrush="{StaticResource SubMenu.Default.Border}" 
                                BorderThickness="1" 
                                Background="{StaticResource SubMenu.Default.Background}">
                        <ScrollViewer x:Name="SubMenuScrollViewer" 
                                            Margin="1,0" 
                                            Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                            <Grid RenderOptions.ClearTypeHint="Enabled">
                                <Canvas HorizontalAlignment="Left" 
                                            Height="0" 
                                            VerticalAlignment="Top" 
                                            Width="0">
                                    <Rectangle x:Name="OpaqueRect" 
                                                    Fill="{StaticResource SubMenu.Default.Background}" 
                                                    Height="{Binding ActualHeight, ElementName=SubMenuBorder}" 
                                                    Width="{Binding ActualWidth, ElementName=SubMenuBorder}"/>
                                </Canvas>
                                <ItemsPresenter x:Name="ItemsPresenter" 
                                                    KeyboardNavigation.DirectionalNavigation="Cycle"
                                                    Grid.IsSharedSizeScope="true" 
                                                    Margin="2" 
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                    KeyboardNavigation.TabNavigation="Cycle"/>
                            </Grid>
                        </ScrollViewer>
                    </Border>
                </Border>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                <Setter Property="Background" TargetName="Shdw" Value="#71000000"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemPressedFill}"/>
                <Setter Property="TextBlock.Foreground" TargetName="Content" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="Fill" TargetName="GlyphPanel" Value="{StaticResource ForegroundBrush.Highlight}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemPressedFill}"/>
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemPressedFill}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="Fill" TargetName="GlyphPanel" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="local:IconImage.Foreground" TargetName="Icon" Value="{StaticResource ForegroundBrush.Disabled}"/>
            </Trigger>
            <Trigger Property="ScrollViewer.CanContentScroll" SourceName="SubMenuScrollViewer" Value="false">
                <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}"/>
                <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle x:Name="Bg"
                            Fill="{TemplateBinding Background}"
                            Margin="1"/>
            <DockPanel>
                <ContentPresenter x:Name="Icon"
                                        ContentSource="Icon"
                                        Margin="4,0,6,0"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                        VerticalAlignment="Center"/>
                <Path x:Name="GlyphPanel"
                            Data="{StaticResource Checkmark}"
                            Fill="{TemplateBinding Foreground}"
                            FlowDirection="LeftToRight"
                            Margin="5,0,0,0"
                            VerticalAlignment="Center" 
                            Height="7.5"
                            Stretch="Fill" 
                            Width="7.5"
                            Visibility="Collapsed"/>
                <ContentPresenter ContentSource="Header"
                                        Margin="{TemplateBinding Padding}"
                                        RecognizesAccessKey="True"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </DockPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemSelectionFill}"/>
                <Setter Property="TextBlock.Foreground" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="Fill" TargetName="GlyphPanel" Value="{StaticResource ForegroundBrush.Highlight}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemPressedFill}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="Fill" TargetName="GlyphPanel" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="local:IconImage.Foreground" TargetName="Icon" Value="{StaticResource ForegroundBrush.Disabled}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Bg" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" SnapsToDevicePixels="true">
            <Grid Margin="-1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="MenuItemColumnGroup" Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="14" SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto"/>
                        <ColumnDefinition Width="4"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition MinWidth="37"/>
                        <ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
                        <ColumnDefinition Width="17"/>
                    </Grid.ColumnDefinitions>

                    <ContentPresenter x:Name="Icon" 
                                      ContentSource="Icon" 
                                      VerticalAlignment="Center"
                                      HorizontalAlignment="Center"
                                      Width="16"
                                      Height="16"
                                      Margin="3" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    <Border x:Name="GlyphPanel" 
                        BorderBrush="Transparent"
                        Margin="1" Visibility="Hidden"> 
                        <Path x:Name="Glyph" 
                            Data="{StaticResource Checkmark}" 
                            Fill="{StaticResource ForegroundBrush}" 
                            FlowDirection="LeftToRight"
                            Margin="5,0,0,0"
                            VerticalAlignment="Center" 
                            Height="7.5"
                            Stretch="Fill" 
                            Width="7.5"/>
                    </Border>
                    <ContentPresenter x:Name="Content" Grid.Column="2"
                                      ContentSource="Header"
                                      Margin="{TemplateBinding Padding}"
                                      RecognizesAccessKey="True" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                      VerticalAlignment="Center"/>
                    <TextBlock x:Name="GestureText" Grid.Column="4" Margin="{TemplateBinding Padding}" Text="{TemplateBinding InputGestureText}" VerticalAlignment="Center"/>
                </Grid>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Background" TargetName="Bg" Value="{StaticResource MenuItemSelectionFill}"/>
                <Setter Property="Fill" TargetName="Glyph" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="TextBlock.Foreground" TargetName="Content" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="local:IconImage.Foreground" TargetName="Icon" Value="{StaticResource ForegroundBrush.Highlight}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="Fill" TargetName="Glyph" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="local:IconImage.Foreground" TargetName="Icon" Value="{StaticResource ForegroundBrush.Disabled}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Bg" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" SnapsToDevicePixels="true">
            <Grid Margin="-1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="MenuItemColumnGroup" Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="14" SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto"/>
                        <ColumnDefinition Width="4"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition MinWidth="37"/>
                        <ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
                        <ColumnDefinition Width="17"/>
                    </Grid.ColumnDefinitions>
                    <ContentPresenter x:Name="Icon"
                                      ContentSource="Icon"
                                      HorizontalAlignment="Center" 
                                      VerticalAlignment="Center"
                                      Width="16"
                                      Height="16"
                                      Margin="3" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    <Border x:Name="GlyphPanel" 
                                Background="Transparent"
                                Margin="1" 
                                Visibility="Hidden">
                        <Path x:Name="Glyph" 
                                    Data="{StaticResource Checkmark}"
                                    Fill="{StaticResource ForegroundBrush}" 
                                    FlowDirection="LeftToRight" 
                                    Margin="5,0,0,0"
                                    VerticalAlignment="Center" 
                                    Height="7.5"
                                    Stretch="Fill" 
                                    Width="7.5"/>
                    </Border>
                    <ContentPresenter x:Name="Content" Grid.Column="2"
                                      ContentSource="Header" 
                                      Margin="{TemplateBinding Padding}" 
                                      RecognizesAccessKey="True" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                      VerticalAlignment="Center"/>
                    <Path x:Name="RightArrowPath" Grid.Column="5" 
                                Data="{StaticResource RightArrow}"
                                Fill="{TemplateBinding Foreground}" 
                                Margin="4,0,0,0" 
                                VerticalAlignment="Center"/>

                    <Popup x:Name="PART_Popup" 
                                AllowsTransparency="true" 
                                Focusable="false" 
                                HorizontalOffset="-2" 
                                IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" 
                                PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
                                Placement="Right" 
                                VerticalOffset="-3">
                        <Border x:Name="Shdw" Background="Transparent">
                            <Border x:Name="SubMenuBorder" 
                                        BorderBrush="{StaticResource SubMenu.Default.Border}"
                                        BorderThickness="1"
                                        Background="{StaticResource SubMenu.Default.Background}">
                                <ScrollViewer x:Name="SubMenuScrollViewer" 
                                                    Margin="1,0" 
                                                    Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                                    <Grid RenderOptions.ClearTypeHint="Enabled">
                                        <Canvas HorizontalAlignment="Left"
                                                    Height="0"
                                                    VerticalAlignment="Top"
                                                    Width="0">
                                            <Rectangle x:Name="OpaqueRect"  
                                                            Fill="{StaticResource SubMenu.Default.Background}" 
                                                            Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
                                                            Width="{Binding ActualWidth, ElementName=SubMenuBorder}"/>
                                        </Canvas>
                                        <ItemsPresenter x:Name="ItemsPresenter" 
                                                            KeyboardNavigation.DirectionalNavigation="Cycle"
                                                            Grid.IsSharedSizeScope="true" 
                                                            Margin="2" 
                                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                            KeyboardNavigation.TabNavigation="Cycle"/>
                                    </Grid>
                                </ScrollViewer>
                            </Border>
                        </Border>
                    </Popup>
                </Grid>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                <Setter Property="Background" TargetName="Shdw" Value="#71000000"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Background" TargetName="Bg" Value="{StaticResource MenuItemSelectionFill}"/>
                <Setter Property="TextBlock.Foreground" TargetName="Content" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="Fill" TargetName="RightArrowPath" Value="{StaticResource ForegroundBrush.Highlight}"/>
                <Setter Property="Fill" TargetName="Glyph" Value="{StaticResource ForegroundBrush.Highlight}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="Fill" TargetName="Glyph" Value="{StaticResource ForegroundBrush.Disabled}"/>
                <Setter Property="local:IconImage.Foreground" TargetName="Icon" Value="{StaticResource ForegroundBrush.Disabled}"/>
            </Trigger>
            <Trigger Property="ScrollViewer.CanContentScroll" SourceName="SubMenuScrollViewer" Value="false">
                <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}"/>
                <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuComboboxItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Bg" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" SnapsToDevicePixels="true">
            <Grid Margin="-1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="MenuItemColumnGroup" Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="14" SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto"/>
                        <ColumnDefinition Width="4"/>
                        <ColumnDefinition MinWidth="120" Width="*"/>
                        <ColumnDefinition Width="17"/>
                    </Grid.ColumnDefinitions>
                    <ContentPresenter Grid.Column="2" x:Name="Content"
                                      ContentSource="Header"
                                      Margin="{TemplateBinding Padding}"
                                      RecognizesAccessKey="True" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                      VerticalAlignment="Center"/>
                </Grid>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Background" TargetName="Bg" Value="{StaticResource MenuItemSelectionFill}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="MinHeight" Value="21"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Height" Value="25"/>
                <Setter Property="Padding" Value="7,6,8,3"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Height" Value="25"/>
                <Setter Property="Padding" Value="7,6,8,3"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Height" Value="21"/>
                <Setter Property="Padding" Value="2,2,2,2"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Height" Value="21"/>
                <Setter Property="Padding" Value="2,2,2,2"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- Separator -->
    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Grid Margin="3,2,3,2" SnapsToDevicePixels="true" UseLayoutRounding="False">
                        <Rectangle Fill="{StaticResource Separator.Background}" Height="1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ListBox -->

    <Style TargetType="{x:Type ListBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource ListBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Padding="1"
                                SnapsToDevicePixels="true">
                        <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="true"/>
                                <!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="2,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="Bd"
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                Padding="{TemplateBinding Padding}" 
                                SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource SelectedListItem}"/>
                            <Setter Property="Foreground" Value="{StaticResource SelectedListItemForeground}"/>
                        </Trigger>
                        <!--<MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
                            </MultiTrigger>-->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsSelected" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource MouseOverListItem}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush.Disabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- GroupBox -->
    <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>
    <Style TargetType="{x:Type GroupBox}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupBox}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="6"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="6"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="6"/>
                        </Grid.RowDefinitions>
                        <Border BorderBrush="Transparent"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}"
                                    Grid.ColumnSpan="4" 
                                    Grid.Column="0"
                                    CornerRadius="3"
                                    Grid.Row="1"
                                    Grid.RowSpan="3">
                            <!--<Border Grid.ColumnSpan="4"
                                    CornerRadius="3"
                                    Grid.Row="1"
                                    Grid.RowSpan="3">-->
                            <Border.OpacityMask>
                                <MultiBinding ConverterParameter="7" Converter="{StaticResource BorderGapMaskConverter}">
                                    <Binding ElementName="Header" Path="ActualWidth"/>
                                    <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
                                    <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
                                </MultiBinding>
                            </Border.OpacityMask>
                            <Border BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="3">
                                <!--<Border BorderBrush="White"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            CornerRadius="4"/>-->
                            </Border>
                        </Border>
                        <Border x:Name="Header"
                                    Grid.Column="1"
                                    Padding="3,1,3,0"
                                    Grid.Row="0"
                                    Grid.RowSpan="2">
                            <ContentPresenter ContentSource="Header"
                                                    RecognizesAccessKey="True"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                        <ContentPresenter Grid.ColumnSpan="2"
                                                Grid.Column="1"
                                                Margin="{TemplateBinding Padding}"
                                                Grid.Row="2"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGrid styles -->

    <!-- DataGridSelectAllButtonStyle -->
    <Style x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Rectangle x:Name="Border" Fill="{StaticResource DataGrid.Header.Background}"
                                   SnapsToDevicePixels="True"/>
                        <Polygon x:Name="Arrow" Fill="Black" HorizontalAlignment="Right" Margin="8,8,3,3"
                                 Opacity="0.15" Points="0,10 10,10 10,0" Stretch="Uniform" VerticalAlignment="Bottom"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Stroke" TargetName="Border" Value="{StaticResource DataGrid.Header.Highlight}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Fill" TargetName="Border" Value="{StaticResource DataGrid.Header.Highlight}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" TargetName="Arrow" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGrid -->
    <Style TargetType="{x:Type DataGrid}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="RowHeight" Value="22" />
        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource DataGrid.Row.Border}"/>
        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource DataGrid.Column.Border}"/>
        <Setter Property="Background" Value="{StaticResource DataGrid.Background}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource DataGrid.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Padding="{TemplateBinding Padding}"
                                SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Button Command="{x:Static DataGrid.SelectAllCommand}"
                                                Focusable="false"
                                                Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}"
                                                Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                                Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

                                        <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"
                                                Grid.Column="1"
                                                Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>

                                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                CanContentScroll="{TemplateBinding CanContentScroll}"
                                                Grid.ColumnSpan="2" Grid.Row="1"/>

                                        <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}"
                                                Orientation="Vertical" Grid.Row="1"
                                                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                                Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                ViewportSize="{TemplateBinding ViewportHeight}"
                                                Style="{StaticResource VerticalScrollBarStyle}"/>
                                        
                                        <Grid Grid.Column="1" Grid.Row="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}"
                                                    Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                                    Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                    ViewportSize="{TemplateBinding ViewportWidth}" Style="{StaticResource HorisontalScrollBarStyle}"/>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="true"/>
                    <!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
                </MultiTrigger.Conditions>
                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <!-- ColumnHeaderGripperStyle -->
    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGridColumnHeader -->
    <Style TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0 0 1 1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource DataGrid.Header.Border}"/>
        <Setter Property="Background" Value="{DynamicResource DataGrid.Header.Background}"/>
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>
        <Setter Property="Padding" Value="7,3,5,2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              RecognizesAccessKey="True"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left"
                                    Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" 
                                    Style="{StaticResource ColumnHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{StaticResource DataGrid.Header.Highlight}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGridRow -->
    <Style TargetType="{x:Type DataGridRow}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource DataGrid.Row.Background}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="ValidationErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRow}">
                    <Border x:Name="DGR_Border"
                            TextElement.Foreground="{TemplateBinding Foreground}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="0"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True">
                        <SelectiveScrollingGrid>
                            <SelectiveScrollingGrid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </SelectiveScrollingGrid.ColumnDefinitions>
                            <SelectiveScrollingGrid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </SelectiveScrollingGrid.RowDefinitions>
                            <DataGridCellsPresenter Grid.Column="1"
                                                    ItemsPanel="{TemplateBinding ItemsPanel}"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1"
                                                      SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                                      Visibility="{TemplateBinding DetailsVisibility}"/>
                            <DataGridRowHeader Grid.RowSpan="2"
                                               SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
                                               Foreground="{TemplateBinding Foreground}"
                                               Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                        </SelectiveScrollingGrid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true"/>
                                <Condition Property="IsSelected" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DGR_Border" Property="Background" Value="{StaticResource DataGrid.Row.Hover}"/>
                        </MultiTrigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" TargetName="DGR_Border" Value="{StaticResource DataGrid.Row.Selected}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsNewItem" Value="True">
                <Setter Property="Margin" Value="{Binding NewItemMargin, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{StaticResource DataGrid.Row.Selected}"/>
            </Trigger>
            <DataTrigger Binding="{Binding IsReadOnly}" Value="True" >
                <Setter Property="IsEnabled" Value="False" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <!-- DataGridCell -->
    <Style TargetType="{x:Type DataGridCell}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Margin" Value="-1"/>
        <Setter Property="Padding" Value="5,0,5,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="True">
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource {x:Static DataGrid.FocusBorderBrushKey}}"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="true"/>
                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{StaticResource DataGrid.Row.Selected}"/>
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- RowHeaderGripperStyle -->
    <Style x:Key="RowHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Height" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeNS"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}"
                                Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGridRowHeader -->
    <Style TargetType="{x:Type DataGridRowHeader}">
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource ToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource ToolTipBetweenShowDelay}"/>

        <Setter Property="Background" Value="{StaticResource DataGrid.Header.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource DataGrid.Header.Border}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
                    <Grid>
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Padding="{TemplateBinding Padding}">
                            <StackPanel Orientation="Horizontal">
                                <ContentPresenter RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                  VerticalAlignment="Center"/>
                                <Control SnapsToDevicePixels="false"
                                         Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"
                                         Visibility="{Binding (Validation.HasError), Converter={StaticResource bool2VisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"/>
                            </StackPanel>
                        </Border>
                        <Thumb x:Name="PART_TopHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Top"/>
                        <Thumb x:Name="PART_BottomHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Bottom"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
