Advertisement
parabola949

DataGridStyle

Feb 17th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 24.16 KB | None | 0 0
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2.                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3.                    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
  4.     <Style TargetType="{x:Type DataGridColumnHeader}">
  5.         <Setter Property="VerticalContentAlignment" Value="Center" />
  6.         <Setter Property="Height" Value="35" />
  7.         <Setter Property="SeparatorBrush" Value="DarkRed" />
  8.         <Setter Property="FontWeight" Value="Black" />
  9.         <Setter Property="Template">
  10.             <Setter.Value>
  11.                 <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
  12.                     <Grid>
  13.                         <VisualStateManager.VisualStateGroups>
  14.                             <VisualStateGroup x:Name="CommonStates">
  15.                                 <VisualState x:Name="Normal" />
  16.                                 <VisualState x:Name="MouseOver">
  17.                                     <Storyboard>
  18.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="columnHeaderBorder" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
  19.                                             <EasingColorKeyFrame KeyTime="0" Value="Black" />
  20.                                         </ColorAnimationUsingKeyFrames>
  21.                                     </Storyboard>
  22.                                 </VisualState>
  23.                             </VisualStateGroup>
  24.                         </VisualStateManager.VisualStateGroups>
  25.                         <Border x:Name="columnHeaderBorder"
  26.                                 BorderThickness="1"
  27.                                 Padding="3,0,3,0">
  28.                             <Border.BorderBrush>
  29.                                 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  30.                                     <GradientStop Offset="0" Color="#A5A5A5" />
  31.                                     <GradientStop Offset="1" Color="#4B4B4B" />
  32.                                 </LinearGradientBrush>
  33.                             </Border.BorderBrush>
  34.                             <Border.Background>
  35.                                 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  36.                                     <GradientStop Offset="0" Color="#FF0A7EDE" />
  37.                                     <GradientStop Offset="1" Color="#FF6800FF" />
  38.                                 </LinearGradientBrush>
  39.                             </Border.Background>
  40.                             <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  41.                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  42.                                               SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  43.                         </Border>
  44.                     </Grid>
  45.                 </ControlTemplate>
  46.             </Setter.Value>
  47.         </Setter>
  48.     </Style>
  49.     <Style TargetType="{x:Type DataGridRow}">
  50.         <Setter Property="Background" Value="Black" />
  51.         <Setter Property="SnapsToDevicePixels" Value="true" />
  52.         <Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
  53.         <Setter Property="ValidationErrorTemplate">
  54.             <Setter.Value>
  55.                 <ControlTemplate>
  56.                     <TextBlock Margin="2,0,0,0"
  57.                                VerticalAlignment="Center"
  58.                                Foreground="Red"
  59.                                Text="!" />
  60.                 </ControlTemplate>
  61.             </Setter.Value>
  62.         </Setter>
  63.         <Setter Property="Template">
  64.             <Setter.Value>
  65.                 <ControlTemplate TargetType="{x:Type DataGridRow}">
  66.                     <Border x:Name="DGR_Border"
  67.                             BorderBrush="{TemplateBinding BorderBrush}"
  68.                             BorderThickness="{TemplateBinding BorderThickness}"
  69.                             SnapsToDevicePixels="True">
  70.                         <Border.Background>
  71.                             <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  72.                                 <GradientStop Offset="0" Color="#AA000000" />
  73.                                 <GradientStop Offset="1" Color="#AA0012C3" />
  74.                             </LinearGradientBrush>
  75.                         </Border.Background>
  76.                         <VisualStateManager.VisualStateGroups>
  77.                             <VisualStateGroup x:Name="CommonStates">
  78.                                 <VisualState x:Name="Normal" />
  79.                                 <VisualState x:Name="Normal_AlternatingRow">
  80.                                     <Storyboard>
  81.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
  82.                                             <EasingColorKeyFrame KeyTime="0" Value="#AAF0C570" />
  83.                                         </ColorAnimationUsingKeyFrames>
  84.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
  85.                                             <EasingColorKeyFrame KeyTime="0" Value="#AAFF7F00" />
  86.                                         </ColorAnimationUsingKeyFrames>
  87.                                     </Storyboard>
  88.                                 </VisualState>
  89.                                 <VisualState x:Name="Normal_Selected">
  90.                                     <Storyboard>
  91.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).                         (GradientBrush.GradientStops)[0].(GradientStop.Color)">
  92.                                             <EasingColorKeyFrame KeyTime="0" Value="#CC222222" />
  93.                                         </ColorAnimationUsingKeyFrames>
  94.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).                         (GradientBrush.GradientStops)[1].(GradientStop.Color)">
  95.                                             <EasingColorKeyFrame KeyTime="0" Value="#77000000" />
  96.                                         </ColorAnimationUsingKeyFrames>
  97.                                     </Storyboard>
  98.                                 </VisualState>
  99.                                 <VisualState x:Name="MouseOver">
  100.                                     <Storyboard>
  101.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).                         (GradientBrush.GradientStops)[0].(GradientStop.Color)">
  102.                                             <EasingColorKeyFrame KeyTime="0" Value="#AA4466FF" />
  103.                                         </ColorAnimationUsingKeyFrames>
  104.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background).                         (GradientBrush.GradientStops)[1].(GradientStop.Color)">
  105.                                             <EasingColorKeyFrame KeyTime="0" Value="#AA0012C3" />
  106.                                         </ColorAnimationUsingKeyFrames>
  107.                                     </Storyboard>
  108.                                 </VisualState>
  109.                             </VisualStateGroup>
  110.                         </VisualStateManager.VisualStateGroups>
  111.                         <SelectiveScrollingGrid>
  112.                             <SelectiveScrollingGrid.ColumnDefinitions>
  113.                                 <ColumnDefinition Width="Auto" />
  114.                                 <ColumnDefinition Width="*" />
  115.                             </SelectiveScrollingGrid.ColumnDefinitions>
  116.                             <SelectiveScrollingGrid.RowDefinitions>
  117.                                 <RowDefinition Height="*" />
  118.                                 <RowDefinition Height="Auto" />
  119.                             </SelectiveScrollingGrid.RowDefinitions>
  120.                             <DataGridCellsPresenter Grid.Column="1"
  121.                                                     ItemsPanel="{TemplateBinding ItemsPanel}"
  122.                                                     SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  123.                             <DataGridDetailsPresenter Grid.Row="1"
  124.                                                       Grid.Column="1"
  125.                                                       SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen,
  126.                                                                                                                      ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical},
  127.                                                                                                                      Converter={x:Static DataGrid.RowDetailsScrollingConverter},
  128.                                                                                                                      RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
  129.                                                       Visibility="{TemplateBinding DetailsVisibility}" />
  130.                             <DataGridRowHeader Grid.RowSpan="2"
  131.                                                SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
  132.                                                Visibility="{Binding HeadersVisibility,
  133.                                                                     ConverterParameter={x:Static DataGridHeadersVisibility.Row},
  134.                                                                     Converter={x:Static DataGrid.HeadersVisibilityConverter},
  135.                                                                     RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
  136.                         </SelectiveScrollingGrid>
  137.                     </Border>
  138.                 </ControlTemplate>
  139.             </Setter.Value>
  140.         </Setter>
  141.     </Style>
  142.     <Style TargetType="{x:Type DataGridCell}">
  143.         <Setter Property="Template">
  144.             <Setter.Value>
  145.                 <ControlTemplate TargetType="{x:Type DataGridCell}">
  146.                     <Border x:Name="border"
  147.                             Background="Transparent"
  148.                             BorderBrush="Transparent"
  149.                             BorderThickness="1"
  150.                             SnapsToDevicePixels="True">
  151.                         <VisualStateManager.VisualStateGroups>
  152.                             <VisualStateGroup x:Name="FocusStates">
  153.                                 <VisualState x:Name="Unfocused" />
  154.                                 <VisualState x:Name="Focused" />
  155.                             </VisualStateGroup>
  156.                             <VisualStateGroup x:Name="CurrentStates">
  157.                                 <VisualState x:Name="Regular" />
  158.                                 <VisualState x:Name="Current">
  159.                                     <Storyboard>
  160.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
  161.                                             <EasingColorKeyFrame KeyTime="0" Value="Gray" />
  162.                                         </ColorAnimationUsingKeyFrames>
  163.                                     </Storyboard>
  164.                                 </VisualState>
  165.                             </VisualStateGroup>
  166.                         </VisualStateManager.VisualStateGroups>
  167.                         <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  168.                     </Border>
  169.                 </ControlTemplate>
  170.             </Setter.Value>
  171.         </Setter>
  172.     </Style>
  173.     <Style TargetType="ToggleButton">
  174.         <Setter Property="Padding" Value="3" />
  175.         <Setter Property="Template">
  176.             <Setter.Value>
  177.                 <ControlTemplate TargetType="ToggleButton">
  178.                     <Grid>
  179.                         <VisualStateManager.VisualStateGroups>
  180.                             <VisualStateGroup x:Name="CommonStates">
  181.                                 <VisualState x:Name="Normal" />
  182.                                 <VisualState x:Name="MouseOver">
  183.                                     <Storyboard>
  184.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="DefaultPath" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)">
  185.                                             <SplineColorKeyFrame KeyTime="0:0:0.2" Value="#AA0000" />
  186.                                         </ColorAnimationUsingKeyFrames>
  187.                                     </Storyboard>
  188.                                 </VisualState>
  189.                                 <VisualState x:Name="Pressed" />
  190.                                 <VisualState x:Name="Disabled" />
  191.                             </VisualStateGroup>
  192.                             <VisualStateGroup x:Name="CheckStates">
  193.                                 <VisualState x:Name="Checked">
  194.                                     <Storyboard>
  195.                                         <ObjectAnimationUsingKeyFrames Duration="0"
  196.                                                                        Storyboard.TargetName="DefaultPath"
  197.                                                                        Storyboard.TargetProperty="Visibility">
  198.                                             <DiscreteObjectKeyFrame KeyTime="0">
  199.                                                 <DiscreteObjectKeyFrame.Value>
  200.                                                     <Visibility>Collapsed</Visibility>
  201.                                                 </DiscreteObjectKeyFrame.Value>
  202.                                             </DiscreteObjectKeyFrame>
  203.                                         </ObjectAnimationUsingKeyFrames>
  204.                                         <ObjectAnimationUsingKeyFrames Duration="0"
  205.                                                                        Storyboard.TargetName="CheckedPath"
  206.                                                                        Storyboard.TargetProperty="Visibility">
  207.                                             <DiscreteObjectKeyFrame KeyTime="0">
  208.                                                 <DiscreteObjectKeyFrame.Value>
  209.                                                     <Visibility>Visible</Visibility>
  210.                                                 </DiscreteObjectKeyFrame.Value>
  211.                                             </DiscreteObjectKeyFrame>
  212.                                         </ObjectAnimationUsingKeyFrames>
  213.                                         <ColorAnimationUsingKeyFrames Storyboard.TargetName="CheckedPath" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)">
  214.                                             <SplineColorKeyFrame KeyTime="0:0:0.2" Value="#CCAA0000" />
  215.                                         </ColorAnimationUsingKeyFrames>
  216.                                     </Storyboard>
  217.                                 </VisualState>
  218.                                 <VisualState x:Name="Unchecked" />
  219.                             </VisualStateGroup>
  220.                         </VisualStateManager.VisualStateGroups>
  221.                         <ContentPresenter x:Name="contentPresenter"
  222.                                           Margin="{TemplateBinding Padding}"
  223.                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  224.                                           VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  225.                                           Content="{TemplateBinding Content}"
  226.                                           ContentTemplate="{TemplateBinding ContentTemplate}" />
  227.                         <Path x:Name="DefaultPath"
  228.                               VerticalAlignment="Top"
  229.                               Data="M0,0 14,7 0,14 Z"
  230.                               Fill="#FF878787"
  231.                               Stretch="Fill" />
  232.                         <Path x:Name="CheckedPath"
  233.                               VerticalAlignment="Top"
  234.                               Data="M0,0 14,0 7,14 Z"
  235.                               Fill="#FF323232"
  236.                               Stretch="Fill"
  237.                               Visibility="Collapsed" />
  238.                     </Grid>
  239.                 </ControlTemplate>
  240.             </Setter.Value>
  241.         </Setter>
  242.     </Style>
  243.     <Style TargetType="{x:Type DataGrid}">
  244.         <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  245.         <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
  246.         <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
  247.         <Setter Property="ScrollViewer.PanningMode" Value="Both" />
  248.         <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  249.         <Setter Property="Template">
  250.             <Setter.Value>
  251.                 <ControlTemplate TargetType="{x:Type DataGrid}">
  252.                     <Border Background="{TemplateBinding Background}"
  253.                             BorderBrush="{TemplateBinding BorderBrush}"
  254.                             BorderThickness="2"
  255.                             CornerRadius="5"
  256.                             Padding="{TemplateBinding Padding}"
  257.                             SnapsToDevicePixels="True">
  258.                         <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
  259.                             <ScrollViewer.Template>
  260.                                 <ControlTemplate TargetType="{x:Type ScrollViewer}">
  261.                                     <Grid>
  262.                                         <Grid.ColumnDefinitions>
  263.                                             <ColumnDefinition Width="Auto" />
  264.                                             <ColumnDefinition Width="*" />
  265.                                             <ColumnDefinition Width="Auto" />
  266.                                         </Grid.ColumnDefinitions>
  267.                                         <Grid.RowDefinitions>
  268.                                             <RowDefinition Height="Auto" />
  269.                                             <RowDefinition Height="*" />
  270.                                             <RowDefinition Height="Auto" />
  271.                                         </Grid.RowDefinitions>
  272.                                         <Button Width="{Binding CellsPanelHorizontalOffset,
  273.                                                                 RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
  274.                                                 Command="{x:Static DataGrid.SelectAllCommand}"
  275.                                                 Focusable="false"
  276.                                                 Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle,
  277.                                                                                               TypeInTargetAssembly={x:Type DataGrid}}}"
  278.                                                 Visibility="{Binding HeadersVisibility,
  279.                                                                      ConverterParameter={x:Static DataGridHeadersVisibility.All},
  280.                                                                      Converter={x:Static DataGrid.HeadersVisibilityConverter},
  281.                                                                      RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
  282.                                         <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"
  283.                                                                         Grid.Column="1"
  284.                                                                         Visibility="{Binding HeadersVisibility,
  285.                                                                                              ConverterParameter={x:Static DataGridHeadersVisibility.Column},
  286.                                                                                              Converter={x:Static DataGrid.HeadersVisibilityConverter},
  287.                                                                                              RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
  288.                                         <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
  289.                                                                 Grid.Row="1"
  290.                                                                 Grid.ColumnSpan="2"
  291.                                                                 CanContentScroll="{TemplateBinding CanContentScroll}" />
  292.                                         <ScrollBar x:Name="PART_VerticalScrollBar"
  293.                                                    Grid.Row="1"
  294.                                                    Grid.Column="2"
  295.                                                    Maximum="{TemplateBinding ScrollableHeight}"
  296.                                                    Orientation="Vertical"
  297.                                                    Style="{DynamicResource MyScrollBar}"
  298.                                                    ViewportSize="{TemplateBinding ViewportHeight}"
  299.                                                    Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
  300.                                                    Value="{Binding VerticalOffset,
  301.                                                                    Mode=OneWay,
  302.                                                                    RelativeSource={RelativeSource TemplatedParent}}" />
  303.                                         <Grid Grid.Row="2" Grid.Column="1">
  304.                                             <Grid.ColumnDefinitions>
  305.                                                 <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
  306.                                                 <ColumnDefinition Width="*" />
  307.                                             </Grid.ColumnDefinitions>
  308.                                             <ScrollBar x:Name="PART_HorizontalScrollBar"
  309.                                                        Grid.Column="1"
  310.                                                        Maximum="{TemplateBinding ScrollableWidth}"
  311.                                                        Orientation="Horizontal"
  312.                                                        ViewportSize="{TemplateBinding ViewportWidth}"
  313.                                                        Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
  314.                                                        Value="{Binding HorizontalOffset,
  315.                                                                        Mode=OneWay,
  316.                                                                        RelativeSource={RelativeSource TemplatedParent}}" />
  317.                                         </Grid>
  318.                                     </Grid>
  319.                                 </ControlTemplate>
  320.                             </ScrollViewer.Template>
  321.                             <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  322.                         </ScrollViewer>
  323.  
  324.                     </Border>
  325.                 </ControlTemplate>
  326.             </Setter.Value>
  327.         </Setter>
  328.         <Style.Triggers>
  329.             <Trigger Property="IsGrouping" Value="True">
  330.                 <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
  331.             </Trigger>
  332.         </Style.Triggers>
  333.     </Style>
  334.     <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />
  335.     <Style TargetType="{x:Type DataGridRowHeader}">
  336.         <Setter Property="Width" Value="25" />
  337.         <Setter Property="Template">
  338.             <Setter.Value>
  339.                 <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
  340.                     <Grid>
  341.                         <Microsoft_Windows_Themes:DataGridHeaderBorder Background="Black"
  342.                                                                        BorderBrush="{TemplateBinding BorderBrush}"
  343.                                                                        BorderThickness="{TemplateBinding BorderThickness}"
  344.                                                                        IsHovered="{TemplateBinding IsMouseOver}"
  345.                                                                        IsPressed="{TemplateBinding IsPressed}"
  346.                                                                        IsSelected="{TemplateBinding IsRowSelected}"
  347.                                                                        Orientation="Horizontal"
  348.                                                                        Padding="{TemplateBinding Padding}"
  349.                                                                        SeparatorBrush="{TemplateBinding SeparatorBrush}"
  350.                                                                        SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
  351.                             <StackPanel Orientation="Horizontal">
  352.                                 <ContentPresenter VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  353.                                 <Control SnapsToDevicePixels="false"
  354.                                          Template="{Binding ValidationErrorTemplate,
  355.                                                             RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"
  356.                                          Visibility="{Binding (Validation.HasError),
  357.                                                               Converter={StaticResource bool2VisibilityConverter},
  358.                                                               RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" />
  359.                             </StackPanel>
  360.                         </Microsoft_Windows_Themes:DataGridHeaderBorder>
  361.                     </Grid>
  362.                 </ControlTemplate>
  363.             </Setter.Value>
  364.         </Setter>
  365.     </Style>
  366. </ResourceDictionary>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement