<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:ModernWpf.Controls"
    xmlns:primitives="clr-namespace:ModernWpf.Controls.Primitives">

    <sys:Double x:Key="DataGridRowMinHeight">32</sys:Double>

    <Style x:Key="DefaultDataGridCellStyle" TargetType="DataGridCell">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="{DynamicResource DataGridCellBackgroundBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="MinHeight" Value="{DynamicResource DataGridRowMinHeight}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridCell">
                    <primitives:DataGridCellPresenter
                        Background="{TemplateBinding Background}"
                        CurrencyVisualBrush="{DynamicResource DataGridCurrencyVisualPrimaryBrush}"
                        CurrencyVisualThickness="1"
                        FocusVisualPrimaryBrush="{DynamicResource DataGridCellFocusVisualPrimaryBrush}"
                        FocusVisualPrimaryThickness="2"
                        FocusVisualSecondaryBrush="{DynamicResource DataGridCellFocusVisualSecondaryBrush}"
                        FocusVisualSecondaryThickness="1"
                        IsCurrencyVisualVisible="{TemplateBinding IsSelected}"
                        IsFocusVisualVisible="{TemplateBinding IsKeyboardFocusWithin}"
                        MinHeight="{TemplateBinding MinHeight}"
                        SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridCellExpanded" TargetType="DataGridCell">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="{DynamicResource DataGridCellBackgroundBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="MinHeight" Value="{DynamicResource DataGridRowMinHeight}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridCell">
                    <Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        MinHeight="{TemplateBinding MinHeight}"
                        SnapsToDevicePixels="True">
                        <Grid>
                            <Rectangle
                                x:Name="CurrencyVisual"
                                Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}"
                                StrokeThickness="1"
                                Fill="Transparent"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                IsHitTestVisible="False"
                                Opacity="0" />
                            <Grid
                                x:Name="FocusVisual"
                                IsHitTestVisible="False"
                                Opacity="0">
                                <Rectangle
                                    Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}"
                                    StrokeThickness="2"
                                    Fill="Transparent"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    IsHitTestVisible="False" />
                                <Rectangle
                                    Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}"
                                    StrokeThickness="1"
                                    Fill="Transparent"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    IsHitTestVisible="False"
                                    Margin="2" />
                            </Grid>
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="CurrencyVisual" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter TargetName="FocusVisual" Property="Opacity" Value="1" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--<Style TargetType="DataGridCell" BasedOn="{StaticResource DefaultDataGridCellStyle}" />-->

    <Style x:Key="DefaultDataGridColumnHeadersPresenterStyle" TargetType="DataGridColumnHeadersPresenter">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridColumnHeadersPresenter">
                    <Grid>
                        <DataGridColumnHeader
                            IsHitTestVisible="False"
                            Name="PART_FillerColumnHeader"
                            SeparatorVisibility="Collapsed" />
                        <ItemsPresenter />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="DataGridColumnHeadersPresenter" BasedOn="{StaticResource DefaultDataGridColumnHeadersPresenterStyle}" />

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

    <Style x:Key="DefaultDataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderBackgroundBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderForegroundBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SeparatorBrush" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="Padding" Value="12,0,0,0" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="MinHeight" Value="32" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridColumnHeader">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="SortIconAscending">M 18.310547 10.126953 L 10.625 2.441406 L 10.625 20 L 9.375 20 L 9.375 2.441406 L 1.689453 10.126953 L 0.810547 9.248047 L 10 0.058594 L 19.189453 9.248047 Z</StreamGeometry>
                        <StreamGeometry x:Key="SortIconDescending">M 19.189453 10.751953 L 10 19.941406 L 0.810547 10.751953 L 1.689453 9.873047 L 9.375 17.558594 L 9.375 0 L 10.625 0 L 10.625 17.558594 L 18.310547 9.873047 Z</StreamGeometry>
                    </ControlTemplate.Resources>
                    <Grid x:Name="ColumnHeaderRoot">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="FocusVisual"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SortStates">
                                <VisualState x:Name="Unsorted" />
                                <VisualState x:Name="SortAscending">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SortDescending">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Data">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SortIconDescending}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Rectangle
                            x:Name="BackgroundRectangle"
                            Stretch="Fill"
                            Fill="{TemplateBinding Background}"
                            Grid.ColumnSpan="2" />

                        <Grid
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Margin="{TemplateBinding Padding}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition x:Name="SortIconColumn" MinWidth="32" Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <ContentPresenter
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                <ContentPresenter.Resources>
                                    <Style TargetType="TextBlock">
                                        <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                                    </Style>
                                </ContentPresenter.Resources>
                            </ContentPresenter>

                            <local:FontIconFallback
                                Grid.Column="1"
                                x:Name="SortIcon"
                                FontFamily="{DynamicResource SymbolThemeFontFamily}"
                                Data="{StaticResource SortIconAscending}"
                                FontSize="12"
                                Foreground="{DynamicResource DataGridColumnHeaderForegroundBrush}"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Visibility="Collapsed" />
                        </Grid>
                        <Rectangle
                            x:Name="VerticalSeparator"
                            Grid.Column="1"
                            Width="1"
                            VerticalAlignment="Stretch"
                            Fill="{TemplateBinding SeparatorBrush}"
                            Visibility="{TemplateBinding SeparatorVisibility}" />

                        <Grid
                            x:Name="FocusVisual"
                            IsHitTestVisible="False"
                            Opacity="0">
                            <Rectangle
                                x:Name="FocusVisualPrimary"
                                Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}"
                                StrokeThickness="2"
                                Fill="Transparent"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                IsHitTestVisible="False" />
                            <Rectangle
                                x:Name="FocusVisualSecondary"
                                Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}"
                                StrokeThickness="1"
                                Fill="Transparent"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                IsHitTestVisible="False"
                                Margin="2" />
                        </Grid>

                        <Thumb
                            x:Name="PART_LeftHeaderGripper"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Left"
                            Style="{StaticResource ColumnHeaderGripperStyle}" />
                        <Thumb
                            x:Name="PART_RightHeaderGripper"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Right"
                            Style="{StaticResource ColumnHeaderGripperStyle}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridColumnHeaderHoveredBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridColumnHeaderPressedBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="SortDirection" Value="{x:Null}">
                            <Setter TargetName="SortIconColumn" Property="MinWidth" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="SortDirection" Value="{x:Null}">
                <Setter Property="Padding" Value="12,0" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource DefaultDataGridColumnHeaderStyle}" />-->

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

    <Style x:Key="DefaultDataGridRowHeaderStyle" TargetType="DataGridRowHeader">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="{DynamicResource DataGridRowHeaderBackgroundBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource DataGridRowHeaderForegroundBrush}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SeparatorBrush" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="Padding" Value="12,0,13,0" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridRowHeader">
                    <Grid x:Name="RowHeaderRoot">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <primitives:VisualStateGroupListener.Listener>
                                    <primitives:VisualStateGroupListener x:Name="CommonStatesListener" />
                                </primitives:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Normal_CurrentRow">
                                    <!-- For optional row currency and editing glyphs
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
                                        <DoubleAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                    </Storyboard>
                                    -->
                                </VisualState>
                                <VisualState x:Name="Normal_Selected">
                                    <Storyboard>
                                        <!-- For optional row currency and editing glyphs
                                        <DoubleAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        -->
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal_EditingRow">
                                    <!-- For optional row currency and editing glyphs
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
                                        <DoubleAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                    </Storyboard>
                                    -->
                                </VisualState>
                                <VisualState x:Name="Normal_CurrentRow_Selected">
                                    <Storyboard />
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <!-- For optional row currency and editing glyphs
                                        <DoubleAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        -->
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver_CurrentRow" />
                                <VisualState x:Name="MouseOver_Unfocused_EditingRow" />
                                <VisualState x:Name="MouseOver_EditingRow" />
                                <VisualState x:Name="MouseOver_Unfocused_Selected" />
                                <VisualState x:Name="MouseOver_Unfocused_CurrentRow_Selected" />
                                <VisualState x:Name="MouseOver_CurrentRow_Selected">
                                    <Storyboard>
                                        <!-- For optional row currency and editing glyphs
                                        <DoubleAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
                                        <DoubleAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        -->
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver_Selected" />
                                <VisualState x:Name="Unfocused_EditingRow" />
                                <VisualState x:Name="Unfocused_Selected" />
                                <VisualState x:Name="Unfocused_CurrentRow_Selected" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="RowValid" />
                                <VisualState x:Name="RowInvalid">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="BackgroundRectangle"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="RowInvalidVisualElement"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.4" />
                                        <!-- For optional row currency and editing glyphs
                                        <ColorAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        <ColorAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        <ColorAnimation Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        <ColorAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        <ColorAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        <ColorAnimation Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Duration="0" To="#FFDC000C"/>
                                        -->
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Border
                            BorderBrush="{TemplateBinding SeparatorBrush}"
                            BorderThickness="0,0,1,0"
                            Grid.RowSpan="3"
                            Grid.ColumnSpan="2">
                            <Grid Background="{TemplateBinding Background}">
                                <Rectangle
                                    x:Name="RowInvalidVisualElement"
                                    Stretch="Fill"
                                    Fill="{DynamicResource DataGridRowInvalidBrush}"
                                    Opacity="0" />
                                <Rectangle
                                    x:Name="BackgroundRectangle"
                                    Stretch="Fill"
                                    Fill="Transparent" />
                            </Grid>
                        </Border>

                        <Rectangle
                            x:Name="HorizontalSeparator"
                            Grid.ColumnSpan="2"
                            Grid.Row="2"
                            Height="1"
                            Margin="1,0,1,0"
                            HorizontalAlignment="Stretch"
                            Fill="{TemplateBinding SeparatorBrush}"
                            Visibility="{TemplateBinding SeparatorVisibility}" />

                        <ContentPresenter
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Margin="{TemplateBinding Padding}"
                            Grid.Column="1"
                            Grid.RowSpan="2"
                            RecognizesAccessKey="True"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <Thumb
                            x:Name="PART_TopHeaderGripper"
                            Grid.ColumnSpan="2"
                            Grid.RowSpan="3"
                            VerticalAlignment="Top"
                            Style="{StaticResource RowHeaderGripperStyle}" />
                        <Thumb
                            x:Name="PART_BottomHeaderGripper"
                            Grid.ColumnSpan="2"
                            Grid.RowSpan="3"
                            VerticalAlignment="Bottom"
                            Style="{StaticResource RowHeaderGripperStyle}" />

                        <!-- For optional row currency glyph
                        <Path x:Name="CurrentRowGlyph" VerticalAlignment="Center" HorizontalAlignment="Center" Width="6" Height="10" Margin="8,0,8,0" Grid.RowSpan="2" Stretch="Fill" Opacity="0" Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z ">
                            <Path.Fill>
                                <LinearGradientBrush StartPoint="0,-.15" EndPoint="0,1.75">
                                    <GradientStop Color="#FF84E3FF" Offset="0"/>
                                    <GradientStop Color="#FF6ABFD8" Offset="0.5"/>
                                    <GradientStop Color="#FF5297AB" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        -->
                        <!-- For optional row editing glyph
                        <Path x:Name="EditingRowGlyph" VerticalAlignment="Center" HorizontalAlignment="Center" Width="6" Height="10" Margin="8,0,8,0" Grid.RowSpan="2" Stretch="Fill" Opacity="0" Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z ">
                            <Path.Fill>
                                <LinearGradientBrush StartPoint="0,-.15" EndPoint="0,1.75">
                                    <GradientStop Color="#FF84E3FF" Offset="0"/>
                                    <GradientStop Color="#FF6ABFD8" Offset="0.5"/>
                                    <GradientStop Color="#FF5297AB" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        -->
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Normal_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Normal_CurrentRow_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_CurrentRow">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Unfocused_EditingRow">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_EditingRow">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Unfocused_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Unfocused_CurrentRow_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_CurrentRow_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Unfocused_EditingRow">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedBackground}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Unfocused_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Unfocused_CurrentRow_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultDataGridRowStyle" TargetType="DataGridRow">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
        <Setter Property="ValidationErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <TextBlock
                        Margin="2,0,0,0"
                        VerticalAlignment="Center"
                        Foreground="Red"
                        Text="!" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridRow">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <primitives:VisualStateGroupListener.Listener>
                                    <primitives:VisualStateGroupListener x:Name="CommonStatesListener" />
                                </primitives:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Normal_AlternatingRow" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Normal_Selected" />
                                <VisualState x:Name="MouseOver_Selected" />
                                <VisualState x:Name="MouseOver_Unfocused_Selected" />
                                <VisualState x:Name="Unfocused_Selected" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle
                            x:Name="BackgroundRectangle"
                            Fill="Transparent" />
                        <Border
                            x:Name="DGR_Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="True">
                            <SelectiveScrollingGrid>
                                <SelectiveScrollingGrid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </SelectiveScrollingGrid.ColumnDefinitions>
                                <SelectiveScrollingGrid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </SelectiveScrollingGrid.RowDefinitions>
                                <DataGridCellsPresenter
                                    x:Name="CellsPresenter"
                                    Grid.Column="1"
                                    ItemsPanel="{TemplateBinding ItemsPanel}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                <Border
                                    Grid.Row="1"
                                    Grid.Column="1"
                                    Background="{DynamicResource DataGridDetailsPresenterBackgroundBrush}">
                                    <DataGridDetailsPresenter
                                        x:Name="DetailsPresenter"
                                        SelectiveScrollingGrid.SelectiveScrollingOrientation="{TemplateBinding primitives:DataGridRowHelper.AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}}"
                                        Visibility="{TemplateBinding DetailsVisibility}" />
                                </Border>
                                <DataGridRowHeader
                                    x:Name="RowHeader"
                                    Grid.RowSpan="2"
                                    SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
                                    Visibility="{TemplateBinding primitives:DataGridRowHelper.HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}}" />
                            </SelectiveScrollingGrid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Normal_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="MouseOver_Unfocused_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" />
                        </Trigger>
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Unfocused_Selected">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackground}" />
                            <Setter TargetName="BackgroundRectangle" Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" />
                        </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>
        </Style.Triggers>
    </Style>

    <!--<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRowStyle}" />-->

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type DataGrid}, ResourceId=DataGridSelectAllButtonStyle}" TargetType="Button">
        <Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderBackgroundBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <Rectangle
                            x:Name="BackgroundRectangle"
                            Fill="{TemplateBinding Background}"
                            SnapsToDevicePixels="True" />
                        <Rectangle
                            Width="1"
                            HorizontalAlignment="Right"
                            Fill="{TemplateBinding BorderBrush}" />
                        <Polygon
                            x:Name="Arrow"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Bottom"
                            Margin="8,8,3,3"
                            Fill="{TemplateBinding Foreground}"
                            Stretch="Uniform"
                            Points="0,10 10,10 10,0" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridColumnHeaderHoveredBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="BackgroundRectangle" Property="Fill" Value="{DynamicResource DataGridColumnHeaderPressedBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Arrow" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridTextBlockStyle" TargetType="TextBlock">
        <Setter Property="Padding" Value="12,0" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Style.Resources>
            <Style TargetType="Hyperlink">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="TextDecorations" Value="Underline" />
                <Setter Property="primitives:HyperlinkHelper.IsPressEnabled" Value="True" />
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter Property="Foreground" Value="{DynamicResource SystemControlHyperlinkBaseMediumBrush}" />
                    </Trigger>
                    <Trigger Property="primitives:HyperlinkHelper.IsPressed" Value="true">
                        <Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightBaseMediumLowBrush}" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Foreground" Value="{DynamicResource SystemControlDisabledBaseMediumLowBrush}" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="true">
                        <Setter Property="Cursor" Value="Hand" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
    </Style>

    <Style x:Key="DefaultDataGridStyle" TargetType="DataGrid">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource DefaultDataGridColumnHeaderStyle}" />
        <Setter Property="RowHeaderStyle" Value="{StaticResource DefaultDataGridRowHeaderStyle}" />
        <Setter Property="RowStyle" Value="{StaticResource DefaultDataGridRowStyle}" />
        <Setter Property="CellStyle" Value="{StaticResource DefaultDataGridCellStyle}" />
        <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
        <Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="VerticalGridLinesBrush" Value="{DynamicResource GridLinesBrush}" />
        <Setter Property="GridLinesVisibility" Value="Horizontal" />
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
        <Setter Property="MinRowHeight" Value="{DynamicResource DataGridRowMinHeight}" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="primitives:DataGridHelper.TextColumnElementStyle" Value="{StaticResource DataGridTextBlockStyle}" />
        <Setter Property="primitives:DataGridHelper.TextColumnEditingElementStyle" Value="{DynamicResource DataGridTextBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.TextColumnFontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="primitives:DataGridHelper.CheckBoxColumnElementStyle" Value="{DynamicResource DataGridReadOnlyCheckBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.CheckBoxColumnEditingElementStyle" Value="{DynamicResource DataGridCheckBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.ComboBoxColumnElementStyle" Value="{DynamicResource DataGridTextBlockComboBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.ComboBoxColumnEditingElementStyle" Value="{DynamicResource DataGridComboBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.HyperlinkColumnElementStyle" Value="{DynamicResource DataGridTextBlockStyle}" />
        <Setter Property="primitives:DataGridHelper.HyperlinkColumnEditingElementStyle" Value="{DynamicResource DataGridTextBoxStyle}" />
        <Setter Property="primitives:DataGridHelper.UseModernColumnStyles" Value="True" />
        <Setter Property="primitives:DataGridHelper.IsEnabled" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGrid">
                    <Border
                        Padding="{TemplateBinding Padding}"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        SnapsToDevicePixels="True">
                        <ScrollViewer
                            x:Name="DG_ScrollViewer"
                            Focusable="false">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="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>

                                        <!-- Left Column Header Corner -->
                                        <Button
                                            Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                            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}}}" />

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

                                        <Rectangle
                                            x:Name="ColumnHeadersAndRowsSeparator"
                                            Grid.ColumnSpan="3"
                                            VerticalAlignment="Bottom"
                                            Width="Auto"
                                            StrokeThickness="1"
                                            Height="1"
                                            Fill="{DynamicResource GridLinesBrush}" />

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

                                        <ScrollBar
                                            x:Name="PART_VerticalScrollBar"
                                            Grid.Row="1"
                                            Grid.Column="2"
                                            Maximum="{TemplateBinding ScrollableHeight}"
                                            Orientation="Vertical"
                                            ViewportSize="{TemplateBinding ViewportHeight}"
                                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                            Value="{TemplateBinding VerticalOffset}" />

                                        <Grid
                                            Grid.Row="2"
                                            Grid.Column="1">
                                            <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"
                                                ViewportSize="{TemplateBinding ViewportWidth}"
                                                Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                                Value="{TemplateBinding HorizontalOffset}" />
                                        </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>

    <Style TargetType="DataGrid" BasedOn="{StaticResource DefaultDataGridStyle}" />

    <Style x:Key="DataGridRowGroupHeaderStyle" TargetType="ToggleButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="ChevronRight">M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z</StreamGeometry>
                        <StreamGeometry x:Key="ChevronDown">M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z</StreamGeometry>
                    </ControlTemplate.Resources>
                    <Grid
                        x:Name="RowGroupHeaderRoot"
                        Background="{DynamicResource DataGridRowGroupHeaderBackgroundBrush}"
                        SnapsToDevicePixels="False">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <local:FontIconFallback
                            x:Name="arrow"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Margin="12,0,0,0"
                            FontFamily="{DynamicResource SymbolThemeFontFamily}"
                            FontSize="12"
                            Data="{StaticResource ChevronRight}"
                            SnapsToDevicePixels="false"
                            Foreground="{TemplateBinding Foreground}" />
                        <ContentPresenter
                            Grid.Column="1"
                            Margin="12,0,0,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            RecognizesAccessKey="True"
                            SnapsToDevicePixels="True" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="arrow" Property="Data" Value="{StaticResource ChevronDown}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="RowGroupHeaderRoot" Property="Background" Value="{DynamicResource DataGridRowGroupHeaderHoveredBackgroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="RowGroupHeaderRoot" Property="Background" Value="{DynamicResource DataGridRowGroupHeaderPressedBackgroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridRowGroupContainerStyle" TargetType="GroupItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="GroupItem">
                    <Expander
                        x:Name="PART_Header"
                        Foreground="{DynamicResource DataGridRowGroupHeaderForegroundBrush}"
                        FontSize="{DynamicResource ControlContentThemeFontSize}"
                        Header="{TemplateBinding Content}"
                        HeaderTemplate="{TemplateBinding ContentTemplate}"
                        HeaderTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                        HeaderStringFormat="{TemplateBinding ContentStringFormat}"
                        IsExpanded="True">
                        <Expander.Template>
                            <ControlTemplate TargetType="Expander">
                                <Border
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    SnapsToDevicePixels="true">
                                    <DockPanel>
                                        <ToggleButton
                                            x:Name="HeaderSite"
                                            MinWidth="0"
                                            MinHeight="{DynamicResource DataGridRowMinHeight}"
                                            Padding="{TemplateBinding Padding}"
                                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                            Content="{TemplateBinding Header}"
                                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                                            ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                            DockPanel.Dock="Top"
                                            FocusVisualStyle="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}"
                                            FontFamily="{TemplateBinding FontFamily}"
                                            FontSize="{TemplateBinding FontSize}"
                                            FontStretch="{TemplateBinding FontStretch}"
                                            FontStyle="{TemplateBinding FontStyle}"
                                            FontWeight="{TemplateBinding FontWeight}"
                                            Foreground="{TemplateBinding Foreground}"
                                            IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                            Style="{StaticResource DataGridRowGroupHeaderStyle}"
                                            primitives:FocusVisualHelper.UseSystemFocusVisuals="True"
                                            primitives:FocusVisualHelper.FocusVisualMargin="0" />
                                        <ContentPresenter
                                            x:Name="ExpandSite"
                                            Margin="{TemplateBinding Padding}"
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            DockPanel.Dock="Bottom"
                                            Focusable="false"
                                            Visibility="Collapsed" />
                                    </DockPanel>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsExpanded" Value="true">
                                        <Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Expander.Template>
                        <ItemsPresenter x:Name="ItemsPresenter" />
                    </Expander>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="DataGridTextControlValidationErrorTemplate">
        <Grid SnapsToDevicePixels="True">
            <AdornedElementPlaceholder />
            <Border
                BorderBrush="{DynamicResource SystemControlErrorTextForegroundBrush}"
                BorderThickness="{DynamicResource TextControlBorderThemeThicknessFocused}" />
        </Grid>
    </ControlTemplate>

</ResourceDictionary>
