Listview.xaml 12 KB

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