The DataGrid control provides a flexible way to display a collection of data in rows and columns. The DataGrid includes built-in column types and a template column for hosting custom content. The built-in row type includes a drop-down details section that you can use to display additional content below the cell values.

Here is a simple style for WPF DataGrid that I want to share with all.

Style features
  1. Rounded Border
  2. Gradient DataGridColumnHeader with MouseOver effect
  3. Custom ValidationErrorTemplate
  4. DataGridRow MouseOver effect
  5. DataGridCell IsSelected effect
1.png
  1. <!--DataGrid -->
  2. <!--Style and template for the resize control on the DataGridColumnHeader.-->
  3. <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
  4. <Setter Property="Width"Value="5"/>
  5. <Setter Property="Background"Value="Transparent"/>
  6. <Setter Property="Cursor"Value="SizeWE"/>
  7. <Setter Property="Template">
  8. <Setter.Value>
  9. <ControlTemplate TargetType="{x:Type Thumb}">
  10. <Border Background="{TemplateBinding Background}"Padding="{TemplateBinding Padding}"/>
  11. </ControlTemplate>
  12. </Setter.Value>
  13. </Setter>
  14. </Style>
  15. <!--Style and template for the DataGridColumnHeader.-->
  16. <Style TargetType="{x:Type DataGridColumnHeader}">
  17. <Setter Property="Background"Value="{DynamicResource NormalBorderBrush}"/>
  18. <Setter Property="Foreground"Value="{DynamicResource TextBrush}"/>
  19. <Setter Property="VerticalContentAlignment"Value="Center"/>
  20. <Setter Property="Height"Value="30"/>
  21. <Setter Property="SeparatorBrush"Value="#FFC9CACA"/>
  22. <Setter Property="FontSize"Value="14"/>
  23. <Setter Property="FontWeight"Value="SemiBold"/>
  24. <Setter Property="Padding"Value="4 0 0 0"/>
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
  28. <ControlTemplate.Resources>
  29. <Storyboard x:Key="HoverOn">
  30. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="Hover"Storyboard.TargetProperty="(UIElement.Opacity)">
  31. <SplineDoubleKeyFrame KeyTime="00:00:00.2000000"Value="1"/>
  32. </DoubleAnimationUsingKeyFrames>
  33. </Storyboard>
  34. <Storyboard x:Key="HoverOff">
  35. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="Hover"Storyboard.TargetProperty="(UIElement.Opacity)">
  36. <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"Value="0"/>
  37. </DoubleAnimationUsingKeyFrames>
  38. </Storyboard>
  39. </ControlTemplate.Resources>
  40. <Grid Background='Transparent'>
  41. <Grid.ColumnDefinitions>
  42. <ColumnDefinition Width='Auto'/>
  43. <ColumnDefinition Width='Auto'/>
  44. <ColumnDefinition Width='*'/>
  45. <ColumnDefinition Width='Auto'/>
  46. </Grid.ColumnDefinitions>
  47. <Rectangle x:Name="BackgroundRectangle"Grid.ColumnSpan="4"Grid.RowSpan="2"
  48. Fill="{StaticResource NormalBrush}"Stretch="Fill"Stroke="{StaticResource NormalBorderBrush}"StrokeThickness="1"/>
  49. <Rectangle x:Name="Hover"Grid.ColumnSpan="4"Grid.RowSpan="2"Stretch="Fill"
  50. Fill="{StaticResource MouseOverBrush}"Opacity="0"/>
  51. <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  52. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  53. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  54. Margin='{TemplateBinding Padding}'
  55. Cursor="{TemplateBinding Cursor}"/>
  56. <Path HorizontalAlignment="Left"x:Name="SortArrow"VerticalAlignment="Center"
  57. Width="8"Opacity="0"RenderTransformOrigin=".5,.5"Grid.Column="2"Grid.RowSpan="2"Fill="#FF000000"Stretch="Uniform"Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
  58. <Path.RenderTransform>
  59. <TransformGroup>
  60. <ScaleTransform ScaleX=".9"ScaleY=".9"x:Name="SortIconTransform"/>
  61. </TransformGroup>
  62. </Path.RenderTransform>
  63. </Path>
  64. <Thumb x:Name="PART_LeftHeaderGripper"Grid.Column="0"HorizontalAlignment="Left"Style="{StaticResource ColumnHeaderGripperStyle}"/>
  65. <Thumb x:Name="PART_RightHeaderGripper"Grid.Column="3"HorizontalAlignment="Right"Style="{StaticResource ColumnHeaderGripperStyle}"/>
  66. </Grid>
  67. <ControlTemplate.Triggers>
  68. <Trigger Property="SortDirection"Value="Ascending">
  69. <Setter TargetName="SortArrow"Property="Opacity"Value="1"/>
  70. <Setter TargetName="SortArrow"Property="RenderTransform">
  71. <Setter.Value>
  72. <RotateTransform Angle="180"/>
  73. </Setter.Value>
  74. </Setter>
  75. <Setter TargetName="BackgroundRectangle"Property="Opacity"Value="1"/>
  76. </Trigger>
  77. <Trigger Property="SortDirection"Value="Descending">
  78. <Setter TargetName="SortArrow"Property="Opacity"Value="1"/>
  79. <Setter TargetName="BackgroundRectangle"Property="Opacity"Value="1"/>
  80. </Trigger>
  81. <Trigger Property="IsMouseOver"Value="true">
  82. <Trigger.EnterActions>
  83. <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
  84. </Trigger.EnterActions>
  85. <Trigger.ExitActions>
  86. <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
  87. </Trigger.ExitActions>
  88. </Trigger>
  89. </ControlTemplate.Triggers>
  90. </ControlTemplate>
  91. </Setter.Value>
  92. </Setter>
  93. </Style>
  94. <!--Style and template for the DataGridColumnHeadersPresenter.-->
  95. <Style TargetType="{x:Type DataGridColumnHeadersPresenter}">
  96. <Setter Property="Template">
  97. <Setter.Value>
  98. <ControlTemplate TargetType="{x:Type DataGridColumnHeadersPresenter}">
  99. <Grid>
  100. <DataGridColumnHeader x:Name="PART_FillerColumnHeader"IsHitTestVisible="False"/>
  101. <ItemsPresenter />
  102. </Grid>
  103. </ControlTemplate>
  104. </Setter.Value>
  105. </Setter>
  106. </Style>
  107. <Style x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}" TargetType="{x:Type Button}">
  108. <Setter Property="Template">
  109. <Setter.Value>
  110. <ControlTemplate TargetType="{x:Type Button}">
  111. <Grid>
  112. <Rectangle x:Name="Border"Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"SnapsToDevicePixels="True"/>
  113. <Polygon x:Name="Arrow"Fill="Black"HorizontalAlignment="Right"Margin="8,8,3,3"Opacity="0.15"Points="0,10 10,10 10,0"Stretch="Uniform"VerticalAlignment="Bottom"/>
  114. </Grid>
  115. <ControlTemplate.Triggers>
  116. <Trigger Property="IsMouseOver"Value="True">
  117. <Setter Property="Stroke"TargetName="Border"Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
  118. </Trigger>
  119. <Trigger Property="IsPressed"Value="True">
  120. <Setter Property="Fill"TargetName="Border"Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
  121. </Trigger>
  122. <Trigger Property="IsEnabled"Value="False">
  123. <Setter Property="Visibility"TargetName="Arrow"Value="Collapsed"/>
  124. </Trigger>
  125. </ControlTemplate.Triggers>
  126. </ControlTemplate>
  127. </Setter.Value>
  128. </Setter>
  129. </Style>
  130. <Style TargetType="{x:Type DataGrid}">
  131. <Setter Property="Background"Value="{StaticResource ControlContentBrush}"/>
  132. <Setter Property="RowDetailsVisibilityMode"Value="VisibleWhenSelected"/>
  133. <Setter Property="ScrollViewer.CanContentScroll"Value="true"/>
  134. <Setter Property="ScrollViewer.PanningMode"Value="Both"/>
  135. <Setter Property="Stylus.IsFlicksEnabled"Value="False"/>
  136. <Setter Property="Margin"Value="5"/>
  137. <Setter Property="BorderBrush"Value="{StaticResource NormalBorderBrush}"/>
  138. <Setter Property="AlternatingRowBackground"Value="{StaticResource AlternateBackgroundBrush}"/>
  139. <Setter Property="HorizontalGridLinesBrush"Value="{StaticResource NormalBorderBrush}"/>
  140. <Setter Property="VerticalGridLinesBrush"Value="{StaticResource NormalBorderBrush}"/>
  141. <Setter Property="Template">
  142. <Setter.Value>
  143. <ControlTemplate TargetType="{x:Type DataGrid}">
  144. <Border BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="2"CornerRadius="5"Background="{TemplateBinding Background}"Padding="{TemplateBinding Padding}"SnapsToDevicePixels="True">
  145. <ScrollViewer x:Name="DG_ScrollViewer"Focusable="false">
  146. <ScrollViewer.Template>
  147. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  148. <Grid>
  149. <Grid.ColumnDefinitions>
  150. <ColumnDefinition Width="Auto"/>
  151. <ColumnDefinition Width="*"/>
  152. <ColumnDefinition Width="Auto"/>
  153. </Grid.ColumnDefinitions>
  154. <Grid.RowDefinitions>
  155. <RowDefinition Height="Auto"/>
  156. <RowDefinition Height="*"/>
  157. <RowDefinition Height="Auto"/>
  158. </Grid.RowDefinitions>
  159. <Button Command="{x:Static DataGrid.SelectAllCommand}"Focusable="false"Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}"Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  160. <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"Grid.Column="1"Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  161. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"CanContentScroll="{TemplateBinding CanContentScroll}"Grid.ColumnSpan="2"Grid.Row="1"/>
  162. <ScrollBar x:Name="PART_VerticalScrollBar"Grid.Column="2"Maximum="{TemplateBinding ScrollableHeight}"Orientation="Vertical"Grid.Row="1"Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"ViewportSize="{TemplateBinding ViewportHeight}"/>
  163. <Grid Grid.Column="1"Grid.Row="2">
  164. <Grid.ColumnDefinitions>
  165. <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  166. <ColumnDefinition Width="*"/>
  167. </Grid.ColumnDefinitions>
  168. <ScrollBar x:Name="PART_HorizontalScrollBar"Grid.Column="1"Maximum="{TemplateBinding ScrollableWidth}"Orientation="Horizontal"Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"ViewportSize="{TemplateBinding ViewportWidth}"/>
  169. </Grid>
  170. </Grid>
  171. </ControlTemplate>
  172. </ScrollViewer.Template>
  173. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  174. </ScrollViewer>
  175. </Border>
  176. </ControlTemplate>
  177. </Setter.Value>
  178. </Setter>
  179. <Style.Triggers>
  180. <Trigger Property="IsGrouping"Value="true">
  181. <Setter Property="ScrollViewer.CanContentScroll"Value="false"/>
  182. </Trigger>
  183. </Style.Triggers>
  184. </Style>
  185. <Style TargetType="{x:Type DataGridRow}">
  186. <Setter Property="SnapsToDevicePixels"Value="true"/>
  187. <Setter Property="Validation.ErrorTemplate"Value="{x:Null}"/>
  188. <Setter Property="ValidationErrorTemplate">
  189. <Setter.Value>
  190. <ControlTemplate>
  191. <Grid>
  192. <Ellipse Width="12"Height="12"Margin="0 2 0 0"
  193. Fill="Red"Stroke="Black"VerticalAlignment="Top"
  194. StrokeThickness="0.5"/>
  195. <TextBlock FontWeight="Bold"Padding="4,0,0,0"
  196. VerticalAlignment="Top"Foreground="White"Text="!"
  197. ToolTip="{Binding (Validation.Errors)[0].ErrorContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}}"/>
  198. </Grid>
  199. </ControlTemplate>
  200. </Setter.Value>
  201. </Setter>
  202. <Setter Property="Template">
  203. <Setter.Value>
  204. <ControlTemplate TargetType="{x:Type DataGridRow}">
  205. <ControlTemplate.Resources>
  206. <Storyboard x:Key="SelectedOn">
  207. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="select_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  208. <SplineDoubleKeyFrame KeyTime="00:00:00.1000000"Value="1"/>
  209. </DoubleAnimationUsingKeyFrames>
  210. </Storyboard>
  211. <Storyboard x:Key="SelectedOff">
  212. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="select_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  213. <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"Value="0"/>
  214. </DoubleAnimationUsingKeyFrames>
  215. </Storyboard>
  216. <Storyboard x:Key="HoverOn">
  217. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="hover_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  218. <SplineDoubleKeyFrame KeyTime="00:00:00.1000000"Value="0.85"/>
  219. </DoubleAnimationUsingKeyFrames>
  220. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="highlight"Storyboard.TargetProperty="(UIElement.Opacity)">
  221. <SplineDoubleKeyFrame KeyTime="00:00:00.1000000"Value="0.65"/>
  222. </DoubleAnimationUsingKeyFrames>
  223. </Storyboard>
  224. <Storyboard x:Key="HoverOff">
  225. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="hover_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  226. <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"Value="0"/>
  227. </DoubleAnimationUsingKeyFrames>
  228. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="highlight"Storyboard.TargetProperty="(UIElement.Opacity)">
  229. <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"Value="0"/>
  230. </DoubleAnimationUsingKeyFrames>
  231. </Storyboard>
  232. </ControlTemplate.Resources>
  233. <Border x:Name="DGR_Border"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"Background="{TemplateBinding Background}"SnapsToDevicePixels="True">
  234. <SelectiveScrollingGrid>
  235. <SelectiveScrollingGrid.ColumnDefinitions>
  236. <ColumnDefinition Width="Auto"/>
  237. <ColumnDefinition Width="*"/>
  238. </SelectiveScrollingGrid.ColumnDefinitions>
  239. <SelectiveScrollingGrid.RowDefinitions>
  240. <RowDefinition Height="*"/>
  241. <RowDefinition Height="Auto"/>
  242. </SelectiveScrollingGrid.RowDefinitions>
  243. <Rectangle x:Name="hover_gradient"Stroke="{DynamicResource FocusBrush}"StrokeThickness="1"RadiusX="1"RadiusY="1"Opacity="0"IsHitTestVisible="False"Grid.Column="1"Fill="{DynamicResource MouseOverBrush}"/>
  244. <Rectangle x:Name="highlight"Margin="1"StrokeThickness="1"RadiusX="0.5"RadiusY="0.5"Opacity="0"IsHitTestVisible="False"Grid.Column="1"Stroke="{DynamicResource MouseOverHighlightBrush}"Fill="{DynamicResource MouseOverHighlightBrush}"/>
  245. <Rectangle x:Name="select_gradient"Grid.Row="0"Grid.ColumnSpan="2"StrokeThickness="1"RadiusX="1"RadiusY="1"Opacity="0"IsHitTestVisible="False"Fill="{DynamicResource PressedBrush}"Stroke="{DynamicResource PressedBorderBrush}"/>
  246. <DataGridCellsPresenter Grid.Column="1"ItemsPanel="{TemplateBinding ItemsPanel}"SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  247. <DataGridDetailsPresenter Grid.Column="1"Grid.Row="1"SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"Visibility="{TemplateBinding DetailsVisibility}"/>
  248. <DataGridRowHeader Grid.RowSpan="2"SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  249. </SelectiveScrollingGrid>
  250. </Border>
  251. <ControlTemplate.Triggers>
  252. <Trigger Property="IsMouseOver"Value="True"SourceName="DGR_Border">
  253. <Trigger.ExitActions>
  254. <BeginStoryboard Storyboard="{StaticResource HoverOff}"x:Name="HoverOff_BeginStoryboard"/>
  255. </Trigger.ExitActions>
  256. <Trigger.EnterActions>
  257. <BeginStoryboard Storyboard="{StaticResource HoverOn}"x:Name="HoverOn_BeginStoryboard"/>
  258. </Trigger.EnterActions>
  259. </Trigger>
  260. <Trigger Property="IsSelected"Value="true">
  261. <Trigger.ExitActions>
  262. <BeginStoryboard x:Name="SelectedOff_BeginStoryboard"Storyboard="{StaticResource SelectedOff}"/>
  263. </Trigger.ExitActions>
  264. <Trigger.EnterActions>
  265. <BeginStoryboard Storyboard="{StaticResource SelectedOn}"/>
  266. </Trigger.EnterActions>
  267. </Trigger>
  268. </ControlTemplate.Triggers>
  269. </ControlTemplate>
  270. </Setter.Value>
  271. </Setter>
  272. </Style>
  273. <Style TargetType="{x:Type DataGridCell}">
  274. <Setter Property="Template">
  275. <Setter.Value>
  276. <ControlTemplate TargetType="{x:Type DataGridCell}">
  277. <ControlTemplate.Resources>
  278. <Storyboard x:Key="SelectedOn">
  279. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="select_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  280. <SplineDoubleKeyFrame KeyTime="00:00:00.1000000"Value="1"/>
  281. </DoubleAnimationUsingKeyFrames>
  282. </Storyboard>
  283. <Storyboard x:Key="SelectedOff">
  284. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"Storyboard.TargetName="select_gradient"Storyboard.TargetProperty="(UIElement.Opacity)">
  285. <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"Value="0"/>
  286. </DoubleAnimationUsingKeyFrames>
  287. </Storyboard>
  288. </ControlTemplate.Resources>
  289. <Border BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"Background="{TemplateBinding Background}"SnapsToDevicePixels="True">
  290. <Grid>
  291. <Rectangle x:Name="select_gradient"Margin="-2 -1 -2 -1"Grid.Column="1"StrokeThickness="1"RadiusX="1"RadiusY="1"Opacity="0"IsHitTestVisible="False"Fill="{DynamicResource PressedBrush}"Stroke="{DynamicResource PressedBorderBrush}"/>
  292. <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  293. </Grid>
  294. </Border>
  295. <ControlTemplate.Triggers>
  296. <Trigger Property="IsSelected"Value="true">
  297. <Trigger.ExitActions>
  298. <BeginStoryboard x:Name="SelectedOff_BeginStoryboard"Storyboard="{StaticResource SelectedOff}"/>
  299. </Trigger.ExitActions>
  300. <Trigger.EnterActions>
  301. <BeginStoryboard Storyboard="{StaticResource SelectedOn}"/>
  302. </Trigger.EnterActions>
  303. </Trigger>
  304. </ControlTemplate.Triggers>
  305. </ControlTemplate>
  306. </Setter.Value>
  307. </Setter>
  308. </Style>
  309. <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />
  310. <Style x:Key="RowHeaderGripperStyle" TargetType="{x:Type Thumb}">
  311. <Setter Property="Height"Value="8"/>
  312. <Setter Property="Background"Value="Transparent"/>
  313. <Setter Property="Cursor"Value="SizeNS"/>
  314. <Setter Property="Template">
  315. <Setter.Value>
  316. <ControlTemplate TargetType="{x:Type Thumb}">
  317. <Border Background="{TemplateBinding Background}"Padding="{TemplateBinding Padding}"/>
  318. </ControlTemplate>
  319. </Setter.Value>
  320. </Setter>
  321. </Style>
  322. <Style TargetType="{x:Type DataGridRowHeader}">
  323. <Setter Property="Width"Value="20"/>
  324. <Setter Property="Template">
  325. <Setter.Value>
  326. <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
  327. <Grid>
  328. <Microsoft_Windows_Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"Background="{TemplateBinding Background}"IsPressed="{TemplateBinding IsPressed}"IsHovered="{TemplateBinding IsMouseOver}"IsSelected="{TemplateBinding IsRowSelected}"Orientation="Horizontal"Padding="{TemplateBinding Padding}"SeparatorBrush="{TemplateBinding SeparatorBrush}"SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
  329. <StackPanel Orientation="Horizontal">
  330. <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"VerticalAlignment="Center"/>
  331. <Control SnapsToDevicePixels="false"Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"Visibility="{Binding (Validation.HasError), Converter={StaticResource bool2VisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"/>
  332. </StackPanel>
  333. </Microsoft_Windows_Themes:DataGridHeaderBorder>
  334. <Thumb x:Name="PART_TopHeaderGripper"Style="{StaticResource RowHeaderGripperStyle}"VerticalAlignment="Top"/>
  335. <Thumb x:Name="PART_BottomHeaderGripper"Style="{StaticResource RowHeaderGripperStyle}"VerticalAlignment="Bottom"/>
  336. </Grid>
  337. </ControlTemplate>
  338. </Setter.Value>
  339. </Setter>
  340. </Style>