<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Styles.Resources>
    <Thickness x:Key="DataGridTextColumnCellTextBlockMargin">12,0,12,0</Thickness>

    <x:Double x:Key="ListAccentLowOpacity">0.6</x:Double>
    <x:Double x:Key="ListAccentMediumOpacity">0.8</x:Double>

    <StreamGeometry x:Key="DataGridSortIconDescendingPath">M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z</StreamGeometry>
    <StreamGeometry x:Key="DataGridSortIconAscendingPath">M1965 947l-941 -941l-941 941l90 90l787 -787v1798h128v-1798l787 787z</StreamGeometry>
    <StreamGeometry x:Key="DataGridRowGroupHeaderIconClosedPath">M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z</StreamGeometry>
    <StreamGeometry x:Key="DataGridRowGroupHeaderIconOpenedPath">M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z</StreamGeometry>

    <SolidColorBrush x:Key="DataGridGridLinesBrush"
                     Color="{StaticResource SystemBaseMediumLowColor}"
                     Opacity="0.4" />
    <SolidColorBrush x:Key="DataGridDropLocationIndicatorBackground"
                     Color="#3F4346" />
    <SolidColorBrush x:Key="DataGridDisabledVisualElementBackground"
                     Color="#8CFFFFFF" />
    <SolidColorBrush x:Key="DataGridFillerGridLinesBrush"
                     Color="Transparent" />
    <SolidColorBrush x:Key="DataGridCurrencyVisualPrimaryBrush"
                     Color="Transparent" />
    <StaticResource x:Key="DataGridColumnHeaderBackgroundColor"
                    ResourceKey="SystemAltHighColor" />
    <SolidColorBrush x:Key="DataGridColumnHeaderBackgroundBrush"
                     Color="{StaticResource DataGridColumnHeaderBackgroundColor}" />
    <StaticResource x:Key="DataGridScrollBarsSeparatorBackground"
                    ResourceKey="SystemChromeLowColor" />
    <StaticResource x:Key="DataGridColumnHeaderForegroundBrush"
                    ResourceKey="SystemControlForegroundBaseMediumBrush" />
    <StaticResource x:Key="DataGridColumnHeaderHoveredBackgroundColor"
                    ResourceKey="SystemListLowColor" />
    <StaticResource x:Key="DataGridColumnHeaderPressedBackgroundColor"
                    ResourceKey="SystemListMediumColor" />
    <StaticResource x:Key="DataGridColumnHeaderDraggedBackgroundBrush"
                    ResourceKey="SystemControlBackgroundChromeMediumLowBrush" />
    <StaticResource x:Key="DataGridColumnHeaderPointerOverBrush"
                    ResourceKey="SystemControlHighlightListLowBrush" />
    <StaticResource x:Key="DataGridColumnHeaderPressedBrush"
                    ResourceKey="SystemControlHighlightListMediumBrush" />
    <StaticResource x:Key="DataGridDetailsPresenterBackgroundBrush"
                    ResourceKey="SystemControlBackgroundChromeMediumLowBrush" />
    <StaticResource x:Key="DataGridFillerColumnGridLinesBrush"
                    ResourceKey="DataGridFillerGridLinesBrush" />
    <StaticResource x:Key="DataGridRowSelectedBackgroundColor"
                    ResourceKey="SystemAccentColor" />
    <StaticResource x:Key="DataGridRowSelectedBackgroundOpacity"
                    ResourceKey="ListAccentLowOpacity" />
    <StaticResource x:Key="DataGridRowSelectedHoveredBackgroundColor"
                    ResourceKey="SystemAccentColor" />
    <StaticResource x:Key="DataGridRowSelectedHoveredBackgroundOpacity"
                    ResourceKey="ListAccentMediumOpacity" />
    <StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundColor"
                    ResourceKey="SystemAccentColor" />
    <StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundOpacity"
                    ResourceKey="ListAccentLowOpacity" />
    <StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundColor"
                    ResourceKey="SystemAccentColor" />
    <StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundOpacity"
                    ResourceKey="ListAccentMediumOpacity" />
    <StaticResource x:Key="DataGridRowHeaderForegroundBrush"
                    ResourceKey="SystemControlForegroundBaseMediumBrush" />
    <StaticResource x:Key="DataGridRowHeaderBackgroundBrush"
                    ResourceKey="SystemControlBackgroundAltHighBrush" />
    <StaticResource x:Key="DataGridRowGroupHeaderBackgroundBrush"
                    ResourceKey="SystemControlBackgroundChromeMediumBrush" />
    <StaticResource x:Key="DataGridRowGroupHeaderHoveredBackgroundBrush"
                    ResourceKey="SystemControlBackgroundListLowBrush" />
    <StaticResource x:Key="DataGridRowGroupHeaderPressedBackgroundBrush"
                    ResourceKey="SystemControlBackgroundListMediumBrush" />
    <StaticResource x:Key="DataGridRowGroupHeaderForegroundBrush"
                    ResourceKey="SystemControlForegroundBaseHighBrush" />
    <StaticResource x:Key="DataGridRowInvalidBrush"
                    ResourceKey="SystemErrorTextColor" />
    <StaticResource x:Key="DataGridCellBackgroundBrush"
                    ResourceKey="SystemControlTransparentBrush" />
    <StaticResource x:Key="DataGridCellFocusVisualPrimaryBrush"
                    ResourceKey="SystemControlFocusVisualPrimaryBrush" />
    <StaticResource x:Key="DataGridCellFocusVisualSecondaryBrush"
                    ResourceKey="SystemControlFocusVisualSecondaryBrush" />
    <StaticResource x:Key="DataGridCellInvalidBrush"
                    ResourceKey="SystemErrorTextColor" />
  </Styles.Resources>

  <Style Selector="DataGridCell">
    <Setter Property="Background" Value="{DynamicResource DataGridCellBackgroundBrush}" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="FontSize" Value="15" />
    <Setter Property="MinHeight" Value="32" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border x:Name="CellBorder"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid x:Name="PART_CellRoot" ColumnDefinitions="*,Auto">

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

            <ContentPresenter Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Foreground="{TemplateBinding Foreground}" />

            <Rectangle x:Name="InvalidVisualElement"
                       HorizontalAlignment="Stretch"
                       VerticalAlignment="Stretch"
                       IsHitTestVisible="False"
                       Stroke="{DynamicResource DataGridCellInvalidBrush}"
                       StrokeThickness="1" />

            <Rectangle Name="PART_RightGridLine"
                       Grid.Column="1"
                       Width="1"
                       VerticalAlignment="Stretch"
                       Fill="{DynamicResource DataGridFillerColumnGridLinesBrush}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGridCell > TextBlock#CellTextBlock">
    <Setter Property="Margin" Value="{DynamicResource DataGridTextColumnCellTextBlockMargin}" />
    <Setter Property="VerticalAlignment" Value="Center" />
  </Style>
  
  <Style Selector="DataGridCell /template/ Rectangle#CurrencyVisual">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridCell /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridCell:current /template/ Rectangle#CurrencyVisual">
    <Setter Property="IsVisible" Value="True" />
  </Style>
  <Style Selector="DataGrid:focus DataGridCell:current /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="True" />
  </Style>
  <Style Selector="DataGridCell /template/ Rectangle#InvalidVisualElement">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridCell:invalid /template/ Rectangle#InvalidVisualElement">
    <Setter Property="IsVisible" Value="True" />
  </Style>
  <Style Selector="DataGridCell > TextBox DataValidationErrors">
    <Setter Property="Template" Value="{DynamicResource TooltipDataValidationContentTemplate}" />
    <Setter Property="ErrorTemplate" Value="{DynamicResource TooltipDataValidationErrorTemplate}" />
  </Style>

  <Style Selector="DataGridColumnHeader">
    <Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderForegroundBrush}" />
    <Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderBackgroundBrush}" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" />
    <Setter Property="Padding" Value="12,0,0,0" />
    <Setter Property="FontSize" Value="12" />
    <Setter Property="MinHeight" Value="32" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border x:Name="HeaderBorder"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid Name="PART_ColumnHeaderRoot" ColumnDefinitions="*,Auto">

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

              <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />

              <Path Name="SortIcon"
                    Grid.Column="1"
                    Height="12"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Fill="{TemplateBinding Foreground}"
                    Stretch="Uniform" />
            </Grid>

            <Rectangle Name="VerticalSeparator"
                       Grid.Column="1"
                       Width="1"
                       VerticalAlignment="Stretch"
                       Fill="{TemplateBinding SeparatorBrush}"
                       IsVisible="{TemplateBinding AreSeparatorsVisible}" />

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

  <Style Selector="DataGridColumnHeader /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridColumnHeader:focus-visible /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="True" />
  </Style>

  <Style Selector="DataGridColumnHeader:pointerover /template/ Grid#PART_ColumnHeaderRoot">
    <Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderHoveredBackgroundColor}" />
  </Style>
  <Style Selector="DataGridColumnHeader:pressed /template/ Grid#PART_ColumnHeaderRoot">
    <Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderPressedBackgroundColor}" />
  </Style>

  <Style Selector="DataGridColumnHeader:dragIndicator">
    <Setter Property="Opacity" Value="0.5" />
  </Style>

  <Style Selector="DataGridColumnHeader /template/ Path#SortIcon">
    <Setter Property="IsVisible" Value="False" />
  </Style>

  <Style Selector="DataGridColumnHeader:sortascending /template/ Path#SortIcon">
    <Setter Property="IsVisible" Value="True" />
    <Setter Property="Data" Value="{StaticResource DataGridSortIconAscendingPath}" />
  </Style>

  <Style Selector="DataGridColumnHeader:sortdescending /template/ Path#SortIcon">
    <Setter Property="IsVisible" Value="True" />
    <Setter Property="Data" Value="{StaticResource DataGridSortIconDescendingPath}" />
  </Style>

  <Style Selector="DataGridRow">
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border x:Name="RowBorder"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <DataGridFrozenGrid Name="PART_Root"
                              ColumnDefinitions="Auto,*"
                              RowDefinitions="*,Auto,Auto">

            <Rectangle Name="BackgroundRectangle"
                       Grid.RowSpan="2"
                       Grid.ColumnSpan="2" />
            <Rectangle x:Name="InvalidVisualElement"
                       Grid.ColumnSpan="2"
                       Fill="{DynamicResource DataGridRowInvalidBrush}" />

            <DataGridRowHeader Name="PART_RowHeader"
                               Grid.RowSpan="3"
                               DataGridFrozenGrid.IsFrozen="True" />
            <DataGridCellsPresenter Name="PART_CellsPresenter"
                                    Grid.Column="1"
                                    DataGridFrozenGrid.IsFrozen="True" />
            <DataGridDetailsPresenter Name="PART_DetailsPresenter"
                                      Grid.Row="1"
                                      Grid.Column="1"
                                      Background="{DynamicResource DataGridDetailsPresenterBackgroundBrush}" />
            <Rectangle Name="PART_BottomGridLine"
                       Grid.Row="2"
                       Grid.Column="1"
                       Height="1"
                       HorizontalAlignment="Stretch" />

          </DataGridFrozenGrid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGridRow">
    <Setter Property="Background" Value="{Binding $parent[DataGrid].RowBackground}" />
  </Style>
  <Style Selector="DataGridRow:nth-child(even)">
    <Setter Property="Background" Value="{Binding $parent[DataGrid].AlternatingRowBackground}" />
  </Style>

  <Style Selector="DataGridRow /template/ Rectangle#InvalidVisualElement">
    <Setter Property="Opacity" Value="0" />
  </Style>
  <Style Selector="DataGridRow:invalid /template/ Rectangle#InvalidVisualElement">
    <Setter Property="Opacity" Value="0.4" />
  </Style>
  <Style Selector="DataGridRow:invalid /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Opacity" Value="0" />
  </Style>

  <Style Selector="DataGridRow /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" />
  </Style>
  <Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" />
  </Style>
  <Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRow:selected:pointerover /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRow:selected:focus /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRow:selected:pointerover:focus /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" />
  </Style>

  <Style Selector="DataGridRowHeader">
    <Setter Property="Background" Value="{DynamicResource DataGridRowHeaderBackgroundBrush}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" />
    <Setter Property="AreSeparatorsVisible" Value="False" />
    <Setter Property="Template">
      <ControlTemplate>
        <Grid x:Name="PART_Root"
              RowDefinitions="*,*,Auto"
              ColumnDefinitions="Auto,*">
          <Border Grid.RowSpan="3"
                  Grid.ColumnSpan="2"
                  BorderBrush="{TemplateBinding SeparatorBrush}"
                  BorderThickness="0,0,1,0">
            <Grid Background="{TemplateBinding Background}">
              <Rectangle x:Name="RowInvalidVisualElement"
                         Fill="{DynamicResource DataGridRowInvalidBrush}"
                         Stretch="Fill" />
              <Rectangle x:Name="BackgroundRectangle"
                         Stretch="Fill" />
            </Grid>
          </Border>
          <Rectangle x:Name="HorizontalSeparator"
                     Grid.Row="2"
                     Grid.ColumnSpan="2"
                     Height="1"
                     Margin="1,0,1,0"
                     HorizontalAlignment="Stretch"
                     Fill="{TemplateBinding SeparatorBrush}"
                     IsVisible="{TemplateBinding AreSeparatorsVisible}" />

          <ContentPresenter Grid.RowSpan="2"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Content="{TemplateBinding Content}" />
        </Grid>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGridRowHeader /template/ Rectangle#RowInvalidVisualElement">
    <Setter Property="Opacity" Value="0" />
  </Style>
  <Style Selector="DataGridRowHeader:invalid /template/ Rectangle#RowInvalidVisualElement">
    <Setter Property="Opacity" Value="0.4" />
  </Style>
  <Style Selector="DataGridRowHeader:invalid /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Opacity" Value="0" />
  </Style>

  <Style Selector="DataGridRowHeader /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" />
  </Style>
  <Style Selector="DataGridRow:pointerover DataGridRowHeader /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" />
  </Style>
  <Style Selector="DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRow:pointerover DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" />
  </Style>
  <Style Selector="DataGridRow:pointerover DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle">
    <Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" />
    <Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" />
  </Style>

  <Style Selector="DataGridRowGroupHeader">
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Foreground" Value="{DynamicResource DataGridRowGroupHeaderForegroundBrush}" />
    <Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderBackgroundBrush}" />
    <Setter Property="FontSize" Value="15" />
    <Setter Property="MinHeight" Value="32" />
    <Setter Property="Template">
      <ControlTemplate>
        <DataGridFrozenGrid Name="PART_Root"
                            MinHeight="{TemplateBinding MinHeight}"
                            ColumnDefinitions="Auto,Auto,Auto,Auto,*"
                            RowDefinitions="*,Auto">

          <Rectangle Name="IndentSpacer"
                     Grid.Column="1" />
          <ToggleButton Name="ExpanderButton"
                        Grid.Column="2"
                        Width="12"
                        Height="12"
                        Margin="12,0,0,0"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Background="{TemplateBinding Background}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        Focusable="False"
                        Foreground="{TemplateBinding Foreground}" />

          <StackPanel Grid.Column="3"
                      Orientation="Horizontal"
                      VerticalAlignment="Center"
                      Margin="12,0,0,0">
            <TextBlock Name="PropertyNameElement"
                       Margin="4,0,0,0"
                       IsVisible="{TemplateBinding IsPropertyNameVisible}"
                       Foreground="{TemplateBinding Foreground}" />
            <TextBlock Margin="4,0,0,0"
                       Text="{Binding Key}"
                       Foreground="{TemplateBinding Foreground}" />
            <TextBlock Name="ItemCountElement"
                       Margin="4,0,0,0"
                       IsVisible="{TemplateBinding IsItemCountVisible}"
                       Foreground="{TemplateBinding Foreground}" />
          </StackPanel>

          <Rectangle x:Name="CurrencyVisual"
                     Grid.ColumnSpan="5"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     Fill="Transparent"
                     IsHitTestVisible="False"
                     Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}"
                     StrokeThickness="1" />
          <Grid x:Name="FocusVisual"
                Grid.ColumnSpan="5"
                IsHitTestVisible="False">
            <Rectangle HorizontalAlignment="Stretch"
                       VerticalAlignment="Stretch"
                       Fill="Transparent"
                       IsHitTestVisible="False"
                       Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}"
                       StrokeThickness="2" />
            <Rectangle Margin="2"
                       HorizontalAlignment="Stretch"
                       VerticalAlignment="Stretch"
                       Fill="Transparent"
                       IsHitTestVisible="False"
                       Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}"
                       StrokeThickness="1" />
          </Grid>

          <DataGridRowHeader Name="PART_RowHeader"
                             Grid.RowSpan="2"
                             DataGridFrozenGrid.IsFrozen="True" />

          <Rectangle x:Name="PART_BottomGridLine"
                     Grid.Row="1"
                     Grid.ColumnSpan="5"
                     Height="1" />
        </DataGridFrozenGrid>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton">
    <Setter Property="Template">
      <ControlTemplate>
        <Border Grid.Column="0"
                Width="12"
                Height="12"
                Background="Transparent"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
          <Path Fill="{TemplateBinding Foreground}"
                HorizontalAlignment="Right"
                VerticalAlignment="Center"
                Stretch="Uniform" />
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton /template/ Path">
    <Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconOpenedPath}" />
    <Setter Property="Stretch" Value="Uniform" />
  </Style>

  <Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path">
    <Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconClosedPath}" />
    <Setter Property="Stretch" Value="UniformToFill" />
  </Style>

  <Style Selector="DataGridRowGroupHeader /template/ DataGridFrozenGrid#PART_Root">
    <Setter Property="Background" Value="{Binding $parent[DataGridRowGroupHeader].Background}" />
  </Style>
  <Style Selector="DataGridRowGroupHeader:pointerover /template/ DataGridFrozenGrid#PART_Root">
    <Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderHoveredBackgroundBrush}" />
  </Style>
  <Style Selector="DataGridRowGroupHeader:pressed /template/ DataGridFrozenGrid#PART_Root">
    <Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderPressedBackgroundBrush}" />
  </Style>

  <Style Selector="DataGridRowGroupHeader /template/ Rectangle#CurrencyVisual">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridRowGroupHeader /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGridRowGroupHeader:current /template/ Rectangle#CurrencyVisual">
    <Setter Property="IsVisible" Value="True" />
  </Style>
  <Style Selector="DataGrid:focus DataGridRowGroupHeader:current /template/ Grid#FocusVisual">
    <Setter Property="IsVisible" Value="True" />
  </Style>

  <Style Selector="DataGrid">
    <Setter Property="RowBackground" Value="Transparent" />
    <Setter Property="AlternatingRowBackground" Value="Transparent" />
    <Setter Property="HeadersVisibility" Value="Column" />
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="SelectionMode" Value="Extended" />
    <Setter Property="GridLinesVisibility" Value="None" />
    <Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" />
    <Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" />
    <Setter Property="DropLocationIndicatorTemplate">
      <Template>
        <Rectangle Fill="{DynamicResource DataGridDropLocationIndicatorBackground}"
                   Width="2" />
      </Template>
    </Setter>
    <Setter Property="Template">
      <ControlTemplate>
        <Border x:Name="DataGridBorder"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto,*,Auto,Auto">
            <Grid.Resources>
              <ControlTemplate x:Key="TopLeftHeaderTemplate"
                               TargetType="DataGridColumnHeader">
                <Grid x:Name="TopLeftHeaderRoot"
                      RowDefinitions="*,*,Auto">
                  <Border Grid.RowSpan="2"
                          BorderThickness="0,0,1,0"
                          BorderBrush="{DynamicResource DataGridGridLinesBrush}" />
                  <Rectangle Grid.RowSpan="2"
                             VerticalAlignment="Bottom"
                             StrokeThickness="1"
                             Height="1"
                             Fill="{DynamicResource DataGridGridLinesBrush}" />
                </Grid>
              </ControlTemplate>
              <ControlTemplate x:Key="TopRightHeaderTemplate"
                               TargetType="DataGridColumnHeader">
                <Grid x:Name="RootElement" />
              </ControlTemplate>
            </Grid.Resources>

            <DataGridColumnHeader Name="PART_TopLeftCornerHeader"
                                  Template="{StaticResource TopLeftHeaderTemplate}" />
            <DataGridColumnHeadersPresenter Name="PART_ColumnHeadersPresenter"
                                            Grid.Column="1"
                                            Grid.ColumnSpan="2" />
            <!--<DataGridColumnHeader Name="PART_TopRightCornerHeader"
                                  Grid.Column="2"
                                  Template="{StaticResource TopRightHeaderTemplate}" />-->
            <Rectangle Name="PART_ColumnHeadersAndRowsSeparator"
                       Grid.ColumnSpan="3"
                       VerticalAlignment="Bottom"
                       Height="1"
                       Fill="{DynamicResource DataGridGridLinesBrush}" />

            <DataGridRowsPresenter Name="PART_RowsPresenter"
                                   Grid.Row="1"
                                   Grid.RowSpan="2"
                                   Grid.ColumnSpan="3">
              <DataGridRowsPresenter.GestureRecognizers>
                <ScrollGestureRecognizer CanHorizontallyScroll="True" CanVerticallyScroll="True" />
              </DataGridRowsPresenter.GestureRecognizers>
            </DataGridRowsPresenter>
            <Rectangle Name="PART_BottomRightCorner"
                       Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}"
                       Grid.Column="2"
                       Grid.Row="2" />
            <!--<Rectangle Name="BottomLeftCorner"
                       Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}"
                       Grid.Row="2"
                       Grid.ColumnSpan="2" />-->
            <ScrollBar Name="PART_VerticalScrollbar"
                       Orientation="Vertical"
                       Grid.Column="2"
                       Grid.Row="1"
                       Width="{DynamicResource ScrollBarSize}" />

            <Grid Grid.Column="1"
                  Grid.Row="2"
                  ColumnDefinitions="Auto,*">
              <Rectangle Name="PART_FrozenColumnScrollBarSpacer" />
              <ScrollBar Name="PART_HorizontalScrollbar"
                         Grid.Column="1"
                         Orientation="Horizontal"
                         Height="{DynamicResource ScrollBarSize}" />
            </Grid>
            <Border x:Name="PART_DisabledVisualElement"
                    Grid.ColumnSpan="3"
                    Grid.RowSpan="4"
                    IsHitTestVisible="False"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    CornerRadius="2"
                    Background="{DynamicResource DataGridDisabledVisualElementBackground}"
                    IsVisible="{Binding !$parent[DataGrid].IsEnabled}" />
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>

  <Style Selector="DataGrid:empty-columns /template/ DataGridColumnHeader#PART_TopLeftCornerHeader">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGrid:empty-columns /template/ DataGridColumnHeadersPresenter#PART_ColumnHeadersPresenter">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="DataGrid:empty-columns /template/ Rectangle#PART_ColumnHeadersAndRowsSeparator">
    <Setter Property="IsVisible" Value="False" />
  </Style>
</Styles>
