DataGrid.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. mc:Ignorable="d">
  7. <SolidColorBrush x:Key="DataGrid_Header_BG" Color="#FF6A82AD"/>
  8. <SolidColorBrush x:Key="DataGrid_Header_BD" Color="Black"/>
  9. <LinearGradientBrush x:Key="DataGrid_Header_BG_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
  10. <GradientStop Color="#FF293968" Offset="0"/>
  11. <GradientStop Color="#FF94A8CB" Offset="1"/>
  12. </LinearGradientBrush>
  13. <SolidColorBrush x:Key="DataGrid_BG_First" Color="#FFEEEEEE"/>
  14. <SolidColorBrush x:Key="DataGrid_BG_Second" Color="#FFDEDEDE"/>
  15. <SolidColorBrush x:Key="DataGrid_Cell_BD" Color="Gray"/>
  16. <SolidColorBrush x:Key="DataGrid_ArrowBG" Color="White"/>
  17. <SolidColorBrush x:Key="DataGrid_BG_Highlight" Color="#262C3D6D"/>
  18. <Style TargetType="{x:Type DataGridCell}">
  19. <Style.Triggers>
  20. <Trigger Property="IsSelected" Value="True">
  21. <Setter Property="Background" Value="CadetBlue" />
  22. </Trigger>
  23. </Style.Triggers>
  24. </Style>
  25. <Style TargetType="{x:Type DataGrid}">
  26. <Setter Property="Background" Value="{x:Null}"/>
  27. <Setter Property="BorderThickness" Value="0"/>
  28. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  29. <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
  30. <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
  31. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  32. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  33. <Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGrid_Cell_BD}"/>
  34. <Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGrid_Cell_BD}"/>
  35. <Setter Property="Margin" Value="0"/>
  36. <Setter Property="Padding" Value="0"/>
  37. <Setter Property="Template">
  38. <Setter.Value>
  39. <ControlTemplate TargetType="{x:Type DataGrid}">
  40. <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false" >
  41. <ScrollViewer.Template>
  42. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  43. <Grid>
  44. <Grid.ColumnDefinitions>
  45. <ColumnDefinition Width="*"/>
  46. <ColumnDefinition Width="Auto"/>
  47. </Grid.ColumnDefinitions>
  48. <Grid.RowDefinitions>
  49. <RowDefinition Height="Auto"/>
  50. <RowDefinition Height="*"/>
  51. <RowDefinition Height="Auto"/>
  52. </Grid.RowDefinitions>
  53. <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  54. <Border BorderBrush="Black" BorderThickness="0,0,1,0"/>
  55. <Grid Grid.Row="1">
  56. <Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1,0,1,1" Background="{DynamicResource DataGrid_BG_First}">
  57. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}"/>
  58. </Border>
  59. </Grid>
  60. <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.RowSpan="2" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
  61. <Grid Grid.Row="2">
  62. <Grid.ColumnDefinitions>
  63. <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  64. <ColumnDefinition Width="*"/>
  65. </Grid.ColumnDefinitions>
  66. <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}"/>
  67. </Grid>
  68. </Grid>
  69. </ControlTemplate>
  70. </ScrollViewer.Template>
  71. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  72. </ScrollViewer>
  73. </ControlTemplate>
  74. </Setter.Value>
  75. </Setter>
  76. <Style.Triggers>
  77. <MultiTrigger>
  78. <MultiTrigger.Conditions>
  79. <Condition Property="IsGrouping" Value="true"/>
  80. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
  81. </MultiTrigger.Conditions>
  82. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  83. </MultiTrigger>
  84. </Style.Triggers>
  85. </Style>
  86. <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter"/>
  87. <Style x:Key="RowHeaderGripperStyle" TargetType="{x:Type Thumb}">
  88. <Setter Property="Height" Value="8"/>
  89. <Setter Property="Background" Value="Transparent"/>
  90. <Setter Property="Cursor" Value="SizeNS"/>
  91. <Setter Property="Template">
  92. <Setter.Value>
  93. <ControlTemplate TargetType="{x:Type Thumb}">
  94. <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
  95. </ControlTemplate>
  96. </Setter.Value>
  97. </Setter>
  98. </Style>
  99. <Style TargetType="{x:Type DataGridRowHeader}">
  100. <Setter Property="BorderBrush" Value="{x:Null}"/>
  101. <Setter Property="BorderThickness" Value="0"/>
  102. <Setter Property="Background" Value="{x:Null}"/>
  103. <Setter Property="Template">
  104. <Setter.Value>
  105. <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
  106. <Grid>
  107. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  108. <StackPanel Orientation="Horizontal">
  109. <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
  110. <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}}}"/>
  111. </StackPanel>
  112. </Border>
  113. <Thumb x:Name="PART_TopHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Top"/>
  114. <Thumb x:Name="PART_BottomHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Bottom"/>
  115. </Grid>
  116. </ControlTemplate>
  117. </Setter.Value>
  118. </Setter>
  119. </Style>
  120. <Style TargetType="{x:Type DataGridRow}">
  121. <Style.Triggers>
  122. <Trigger Property="ItemsControl.AlternationIndex" Value="0">
  123. <Setter Property="Background" Value="{DynamicResource DataGrid_BG_First}"/>
  124. </Trigger>
  125. <Trigger Property="ItemsControl.AlternationIndex" Value="1">
  126. <Setter Property="Background" Value="{DynamicResource DataGrid_BG_Second}"/>
  127. </Trigger>
  128. </Style.Triggers>
  129. </Style>
  130. <Style TargetType="{x:Type DataGridColumnHeadersPresenter}">
  131. <Setter Property="MinHeight" Value="24"/>
  132. <Setter Property="BorderBrush" Value="{DynamicResource DataGrid_Header_BD}"/>
  133. <Setter Property="Background" Value="{DynamicResource DataGrid_Header_BG}"/>
  134. <Setter Property="Template">
  135. <Setter.Value>
  136. <ControlTemplate TargetType="{x:Type DataGridColumnHeadersPresenter}">
  137. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}">
  138. <ItemsPresenter />
  139. </Border>
  140. </ControlTemplate>
  141. </Setter.Value>
  142. </Setter>
  143. </Style>
  144. <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
  145. <Setter Property="Width" Value="8"/>
  146. <Setter Property="Background" Value="Transparent"/>
  147. <Setter Property="Cursor" Value="SizeWE"/>
  148. <Setter Property="Template">
  149. <Setter.Value>
  150. <ControlTemplate TargetType="{x:Type Thumb}">
  151. <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
  152. </ControlTemplate>
  153. </Setter.Value>
  154. </Setter>
  155. </Style>
  156. <Style TargetType="{x:Type DataGridColumnHeader}">
  157. <Setter Property="SnapsToDevicePixels" Value="True"/>
  158. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  159. <Setter Property="BorderBrush" Value="{DynamicResource DataGrid_Header_BD}"/>
  160. <Setter Property="BorderThickness" Value="0,0,1,0"/>
  161. <Setter Property="Padding" Value="5,1"/>
  162. <Setter Property="Background" Value="{DynamicResource DataGrid_Header_BG}"/>
  163. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  164. <Setter Property="MinHeight" Value="24"/>
  165. <Setter Property="Template">
  166. <Setter.Value>
  167. <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
  168. <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Cursor="Hand">
  169. <Grid>
  170. <Path x:Name="Arrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Width="8" Height="4" Fill="{DynamicResource DataGrid_ArrowBG}" Margin="0,2,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.4" />
  171. <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  172. <ContentPresenter.Effect>
  173. <DropShadowEffect BlurRadius="0" ShadowDepth="1" Direction="315"/>
  174. </ContentPresenter.Effect>
  175. </ContentPresenter>
  176. <Thumb x:Name="PART_RightHeaderGripper" Style="{StaticResource ColumnHeaderGripperStyle}" HorizontalAlignment="Right"/>
  177. </Grid>
  178. </Border>
  179. <ControlTemplate.Triggers>
  180. <Trigger Property="SortDirection" Value="Ascending">
  181. <Setter TargetName="Arrow" Property="Visibility" Value="Visible" />
  182. <Setter TargetName="Arrow" Property="RenderTransform">
  183. <Setter.Value>
  184. <RotateTransform Angle="180" />
  185. </Setter.Value>
  186. </Setter>
  187. <Setter Property="Background" Value="{DynamicResource DataGrid_Header_BG_MouseOver}"/>
  188. </Trigger>
  189. <Trigger Property="SortDirection" Value="Descending">
  190. <Setter TargetName="Arrow" Property="Visibility" Value="Visible" />
  191. <Setter Property="Background" Value="{DynamicResource DataGrid_Header_BG_MouseOver}"/>
  192. </Trigger>
  193. <MultiTrigger>
  194. <MultiTrigger.Conditions>
  195. <Condition Property="IsMouseOver" Value="True" />
  196. <Condition Property="SortDirection" Value="{x:Null}" />
  197. </MultiTrigger.Conditions>
  198. <Setter Property="Background" Value="{DynamicResource DataGrid_Header_BG_MouseOver}"/>
  199. </MultiTrigger>
  200. </ControlTemplate.Triggers>
  201. </ControlTemplate>
  202. </Setter.Value>
  203. </Setter>
  204. </Style>
  205. <SolidColorBrush x:Key="{x:Static DataGrid.FocusBorderBrushKey}" Color="#FF000000"/>
  206. <!--
  207. <Style TargetType="{x:Type DataGridCellsPresenter}">
  208. <Setter Property="Height" Value="24"/>
  209. <Setter Property="BorderBrush" Value="{DynamicResource DataGrid_Cell_BD}"/>
  210. <Setter Property="BorderThickness" Value="0,0,0,1"/>
  211. <Setter Property="Background" Value="Transparent"/>
  212. <Setter Property="Template">
  213. <Setter.Value>
  214. <ControlTemplate TargetType="{x:Type DataGridCellsPresenter}">
  215. <Grid>
  216. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"/>
  217. <ItemsPresenter Margin="0"/>
  218. </Grid>
  219. </ControlTemplate>
  220. </Setter.Value>
  221. </Setter>
  222. </Style>
  223. <Style TargetType="{x:Type DataGridCell}">
  224. <Setter Property="Background" Value="Transparent"/>
  225. <Setter Property="BorderBrush" Value="{DynamicResource DataGrid_Cell_BD}"/>
  226. <Setter Property="Foreground" Value="Black"/>
  227. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  228. <Setter Property="VerticalContentAlignment" Value="Center"/>
  229. <Setter Property="BorderThickness" Value="0"/>
  230. <Setter Property="Height" Value="24"/>
  231. <Setter Property="Margin" Value="0"/>
  232. <Setter Property="Padding" Value="3,1"/>
  233. <Setter Property="Template">
  234. <Setter.Value>
  235. <ControlTemplate TargetType="{x:Type DataGridCell}">
  236. <Border x:Name="BG" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="True" Cursor="Hand">
  237. <Grid>
  238. <Rectangle x:Name="Highlight" Fill="{DynamicResource DataGrid_BG_Highlight}" Opacity="0"/>
  239. <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/>
  240. </Grid>
  241. </Border>
  242. <ControlTemplate.Triggers>
  243. <Trigger Property="IsSelected" Value="True">
  244. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  245. </Trigger>
  246. <MultiTrigger>
  247. <MultiTrigger.Conditions>
  248. <Condition Property="IsSelected" Value="true"/>
  249. <Condition Property="Selector.IsSelectionActive" Value="false"/>
  250. </MultiTrigger.Conditions>
  251. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  252. </MultiTrigger>
  253. <MultiTrigger>
  254. <MultiTrigger.Conditions>
  255. <Condition Property="IsMouseOver" Value="True" />
  256. </MultiTrigger.Conditions>
  257. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  258. </MultiTrigger>
  259. <Trigger Property="IsEnabled" Value="false">
  260. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  261. </Trigger>
  262. </ControlTemplate.Triggers>
  263. </ControlTemplate>
  264. </Setter.Value>
  265. </Setter>
  266. </Style>
  267. -->
  268. </ResourceDictionary>