Listview.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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="Listview_Header_BD" Color="#FF233661"/>
  8. <SolidColorBrush x:Key="Listview_Header_FG" Color="White"/>
  9. <SolidColorBrush x:Key="Listview_Header_BG_Mouseover" Color="#FF57A3D4"/>
  10. <SolidColorBrush x:Key="Listview_Header_BD_Highlight" Color="#FFB3B9D1"/>
  11. <SolidColorBrush x:Key="Listview_FG_Highlight" Color="#FF233863"/>
  12. <SolidColorBrush x:Key="Listview_BG_Highlight" Color="#FF3399FF"/>
  13. <SolidColorBrush x:Key="Listview_BG_First" Color="#FFEEEEEE"/>
  14. <SolidColorBrush x:Key="Listview_BG_Second" Color="#FFDEDEDE"/>
  15. <SolidColorBrush x:Key="Listview_Header_BG" Color="#FF2F457F"/>
  16. <SolidColorBrush x:Key="Listview_Content_BD" Color="#FF999999"/>
  17. <!-- Listview ColumnHeader ControlTemplate -->
  18. <Style TargetType="{x:Type GridViewColumnHeader}">
  19. <Setter Property="FontFamily" Value="Arial"/>
  20. <Setter Property="Foreground" Value="{DynamicResource Listview_Header_FG}"/>
  21. <Setter Property="FontSize" Value="14"/>
  22. <Setter Property="MinHeight" Value="24"/>
  23. <Setter Property="Template">
  24. <Setter.Value>
  25. <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
  26. <Border x:Name="BG" BorderBrush="{DynamicResource Listview_Header_BD_Highlight}" BorderThickness="1,1,0,0" Background="{DynamicResource Listview_Header_BG}" Cursor="Hand">
  27. <Border x:Name="Inner_BD" SnapsToDevicePixels="true" BorderBrush="{DynamicResource Listview_Header_BD}" BorderThickness="0,0,1,0">
  28. <Grid>
  29. <ContentPresenter x:Name="HeaderContent" Margin="5,1" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True" RecognizesAccessKey="True">
  30. </ContentPresenter>
  31. <Thumb x:Name="PART_HeaderGripper" Width="8" HorizontalAlignment="Right" Style="{DynamicResource Thumb-ListViewItem}" Margin="0,0,-4,0"/>
  32. </Grid>
  33. </Border>
  34. </Border>
  35. <ControlTemplate.Triggers>
  36. <Trigger Property="IsMouseOver" Value="True">
  37. <Setter Property="Background" TargetName="BG" Value="{DynamicResource Listview_Header_BG_Mouseover}"/>
  38. <Setter Property="Foreground" Value="{DynamicResource Listview_FG_Highlight}"/>
  39. </Trigger>
  40. </ControlTemplate.Triggers>
  41. </ControlTemplate>
  42. </Setter.Value>
  43. </Setter>
  44. </Style>
  45. <Style x:Key="OnlyGripper_GridViewColumnHeader" TargetType="{x:Type GridViewColumnHeader}">
  46. <Setter Property="MinHeight" Value="24"/>
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
  50. <Grid x:Name="Grid" SnapsToDevicePixels="true">
  51. <ContentPresenter x:Name="OnlyGripper_HeaderContent" Margin="5,0" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
  52. <Thumb Width="10" HorizontalAlignment="Right" Style="{DynamicResource Thumb-ListViewItem}" Margin="-5,0"/>
  53. </Grid>
  54. </ControlTemplate>
  55. </Setter.Value>
  56. </Setter>
  57. </Style>
  58. <!-- listview Item Style -->
  59. <Style TargetType="{x:Type ListViewItem}">
  60. <Setter Property="Background" Value="Transparent"/>
  61. <Setter Property="Foreground" Value="Black"/>
  62. <Setter Property="FontSize" Value="14"/>
  63. <Setter Property="TextBlock.TextAlignment" Value="Left"/>
  64. <Setter Property="MinHeight" Value="24"/>
  65. <Setter Property="MinWidth" Value="50"/>
  66. <Setter Property="Template">
  67. <Setter.Value>
  68. <ControlTemplate TargetType="{x:Type ListViewItem}">
  69. <Border x:Name="BG" Background="{TemplateBinding Background}" BorderThickness="0,0,0,1" BorderBrush="Gray" SnapsToDevicePixels="True" Cursor="Hand">
  70. <Grid>
  71. <Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
  72. <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
  73. </Grid>
  74. </Border>
  75. <ControlTemplate.Triggers>
  76. <Trigger Property="IsSelected" Value="True">
  77. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  78. <Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
  79. <Setter Property="Foreground" Value="White"/>
  80. <Setter Property="Margin" TargetName="Highlight" Value="0,-1"/>
  81. </Trigger>
  82. <Trigger Property="IsMouseOver" Value="True">
  83. <Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
  84. </Trigger>
  85. </ControlTemplate.Triggers>
  86. </ControlTemplate>
  87. </Setter.Value>
  88. </Setter>
  89. <Style.Triggers>
  90. <Trigger Property="ListView.AlternationIndex" Value="0">
  91. <Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
  92. </Trigger>
  93. <Trigger Property="ListView.AlternationIndex" Value="1">
  94. <Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
  95. </Trigger>
  96. </Style.Triggers>
  97. </Style>
  98. <!-- listview Style -->
  99. <Style x:Key="ListView-ScrollViewer" TargetType="{x:Type ScrollViewer}">
  100. <Setter Property="SnapsToDevicePixels" Value="True"/>
  101. <Setter Property="CanContentScroll" Value="False"/>
  102. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  103. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  104. <Setter Property="Template">
  105. <Setter.Value>
  106. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  107. <Grid>
  108. <Grid.ColumnDefinitions>
  109. <ColumnDefinition Width="*"/>
  110. <ColumnDefinition Width="Auto"/>
  111. </Grid.ColumnDefinitions>
  112. <Grid.RowDefinitions>
  113. <RowDefinition Height="Auto"/>
  114. <RowDefinition Height="*"/>
  115. <RowDefinition Height="Auto"/>
  116. </Grid.RowDefinitions>
  117. <Grid>
  118. <Border x:Name ="TopBG" MinHeight="24" BorderBrush="{DynamicResource Listview_Header_BD}" BorderThickness="1" Background="{DynamicResource Listview_Header_BG}"/>
  119. <ScrollViewer Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
  120. <ScrollViewer.LayoutTransform>
  121. <TransformGroup>
  122. <ScaleTransform/>
  123. <SkewTransform/>
  124. <RotateTransform/>
  125. <TranslateTransform/>
  126. </TransformGroup>
  127. </ScrollViewer.LayoutTransform>
  128. <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  129. AllowsColumnReorder="{Binding TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}"
  130. ColumnHeaderContainerStyle="{Binding TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}"
  131. ColumnHeaderContextMenu="{Binding TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
  132. ColumnHeaderTemplate="{Binding TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}"
  133. ColumnHeaderToolTip="{Binding TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}"
  134. Columns="{Binding TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"/>
  135. </ScrollViewer>
  136. </Grid>
  137. <Grid Grid.Row="1">
  138. <Border BorderThickness="1,0,1,1" Background="{DynamicResource Listview_BG_First}" BorderBrush="{DynamicResource Listview_Content_BD}">
  139. <ScrollContentPresenter Name="PART_ScrollContentPresenter"
  140. CanContentScroll="{TemplateBinding CanContentScroll}"
  141. KeyboardNavigation.DirectionalNavigation="Local"
  142. CanHorizontallyScroll="False"
  143. CanVerticallyScroll="False"
  144. ContentTemplate="{TemplateBinding ContentTemplate}"
  145. Content="{TemplateBinding Content}"/>
  146. </Border>
  147. </Grid>
  148. <ScrollBar x:Name="PART_HorizontalScrollBar" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="2" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal"/>
  149. <ScrollBar x:Name="PART_VerticalScrollBar" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.RowSpan="2" Grid.Row="0" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="0"/>
  150. <DockPanel Grid.Column="1" Grid.Row="2" LastChildFill="False"/>
  151. </Grid>
  152. </ControlTemplate>
  153. </Setter.Value>
  154. </Setter>
  155. </Style>
  156. <Style x:Key="Thumb-ListViewItem" TargetType="{x:Type Thumb}">
  157. <Setter Property="Width" Value="8"/>
  158. <Setter Property="Template">
  159. <Setter.Value>
  160. <ControlTemplate TargetType="{x:Type Thumb}">
  161. <Border Padding="{TemplateBinding Padding}" Background="Transparent">
  162. <Rectangle HorizontalAlignment="Center" Width="1" Opacity="1" />
  163. </Border>
  164. </ControlTemplate>
  165. </Setter.Value>
  166. </Setter>
  167. </Style>
  168. <Style TargetType="{x:Type ListView}">
  169. <Setter Property="SnapsToDevicePixels" Value="True"/>
  170. <Setter Property="OverridesDefaultStyle" Value="True"/>
  171. <Setter Property="Template">
  172. <Setter.Value>
  173. <ControlTemplate TargetType="{x:Type ListView}">
  174. <Border Name="Border">
  175. <ScrollViewer Style="{DynamicResource ListView-ScrollViewer}">
  176. <ItemsPresenter Grid.Row="0"/>
  177. </ScrollViewer>
  178. </Border>
  179. </ControlTemplate>
  180. </Setter.Value>
  181. </Setter>
  182. </Style>
  183. </ResourceDictionary>