ScrollViewerStyle.xaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
  3. <Setter Property="SnapsToDevicePixels" Value="True" />
  4. <Setter Property="OverridesDefaultStyle" Value="true" />
  5. <Setter Property="Focusable" Value="false" />
  6. <Setter Property="Template">
  7. <Setter.Value>
  8. <ControlTemplate TargetType="{x:Type RepeatButton}">
  9. <Border Name="Border"
  10. Margin="0"
  11. Background="{DynamicResource ScrollButtonBrush}"
  12. BorderBrush="{DynamicResource CommonBorderBrush}"
  13. BorderThickness="1"
  14. CornerRadius="0">
  15. <Path Name="Path"
  16. HorizontalAlignment="Center"
  17. VerticalAlignment="Center"
  18. Data="{Binding Path=Content,
  19. RelativeSource={RelativeSource TemplatedParent}}"
  20. Fill="{DynamicResource ScrollBarFill}" />
  21. </Border>
  22. <ControlTemplate.Triggers>
  23. <Trigger Property="IsPressed" Value="true">
  24. <!-- <Setter TargetName="Border" Property="Background" Value="{DynamicResource PressedBrush}" /> -->
  25. <Setter TargetName="Path" Property="Fill" Value="{DynamicResource ButtonPressBrush}" />
  26. </Trigger>
  27. <Trigger Property="IsEnabled" Value="false">
  28. <Setter Property="Foreground" Value="{DynamicResource ButtonDisEnableColor}" />
  29. </Trigger>
  30. </ControlTemplate.Triggers>
  31. </ControlTemplate>
  32. </Setter.Value>
  33. </Setter>
  34. </Style>
  35. <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
  36. <Setter Property="SnapsToDevicePixels" Value="True" />
  37. <Setter Property="OverridesDefaultStyle" Value="true" />
  38. <Setter Property="IsTabStop" Value="false" />
  39. <Setter Property="Focusable" Value="false" />
  40. <Setter Property="Template">
  41. <Setter.Value>
  42. <ControlTemplate TargetType="{x:Type RepeatButton}">
  43. <Border Background="Transparent"
  44. BorderBrush="{TemplateBinding BorderBrush}"
  45. BorderThickness="{TemplateBinding BorderThickness}" />
  46. </ControlTemplate>
  47. </Setter.Value>
  48. </Setter>
  49. </Style>
  50. <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
  51. <Setter Property="SnapsToDevicePixels" Value="True" />
  52. <Setter Property="OverridesDefaultStyle" Value="true" />
  53. <Setter Property="BorderBrush" Value="{DynamicResource CommonBorderBrush}" />
  54. <Setter Property="BorderThickness" Value="1" />
  55. <Setter Property="Background" Value="{DynamicResource ScrollThumbBackground}" />
  56. <Setter Property="IsTabStop" Value="false" />
  57. <Setter Property="Focusable" Value="false" />
  58. <Setter Property="Template">
  59. <Setter.Value>
  60. <ControlTemplate TargetType="{x:Type Thumb}">
  61. <Border Background="{TemplateBinding Background}"
  62. BorderBrush="{TemplateBinding BorderBrush}"
  63. BorderThickness="{TemplateBinding BorderThickness}"
  64. CornerRadius="0" />
  65. </ControlTemplate>
  66. </Setter.Value>
  67. </Setter>
  68. </Style>
  69. <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
  70. <Grid>
  71. <Grid.RowDefinitions>
  72. <RowDefinition MaxHeight="18" />
  73. <RowDefinition Height="0.00001*" />
  74. <RowDefinition MaxHeight="18" />
  75. </Grid.RowDefinitions>
  76. <Border Grid.RowSpan="3"
  77. Background="{DynamicResource ScrollBackground}"
  78. CornerRadius="0" />
  79. <RepeatButton Grid.Row="0"
  80. Height="18"
  81. Command="ScrollBar.LineUpCommand"
  82. Content="M 0 4 L 8 4 L 4 0 Z"
  83. Style="{DynamicResource ScrollBarLineButton}" />
  84. <Track Name="PART_Track"
  85. Grid.Row="1"
  86. Margin="1,0"
  87. IsDirectionReversed="true">
  88. <Track.DecreaseRepeatButton>
  89. <RepeatButton Command="ScrollBar.PageUpCommand" Style="{DynamicResource ScrollBarPageButton}" />
  90. </Track.DecreaseRepeatButton>
  91. <Track.Thumb>
  92. <Thumb Margin="0,0,0,0"
  93. Background="{DynamicResource ScrollThumbBackground}"
  94. Style="{DynamicResource ScrollBarThumb}" />
  95. </Track.Thumb>
  96. <Track.IncreaseRepeatButton>
  97. <RepeatButton Command="ScrollBar.PageDownCommand" Style="{DynamicResource ScrollBarPageButton}" />
  98. </Track.IncreaseRepeatButton>
  99. </Track>
  100. <RepeatButton Grid.Row="2"
  101. Height="18"
  102. Command="ScrollBar.LineDownCommand"
  103. Content="M 0 0 L 4 4 L 8 0 Z"
  104. Style="{DynamicResource ScrollBarLineButton}" />
  105. </Grid>
  106. </ControlTemplate>
  107. <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
  108. <Grid>
  109. <Grid.ColumnDefinitions>
  110. <ColumnDefinition MaxWidth="18" />
  111. <ColumnDefinition Width="0.00001*" />
  112. <ColumnDefinition MaxWidth="18" />
  113. </Grid.ColumnDefinitions>
  114. <Border Grid.ColumnSpan="3"
  115. Background="{DynamicResource ScrollBackground}"
  116. CornerRadius="0" />
  117. <RepeatButton Grid.Column="0"
  118. Width="18"
  119. Command="ScrollBar.LineLeftCommand"
  120. Content="M 4 0 L 4 8 L 0 4 Z"
  121. Style="{DynamicResource ScrollBarLineButton}" />
  122. <Track Name="PART_Track"
  123. Grid.Column="1"
  124. Margin="0,1"
  125. IsDirectionReversed="False">
  126. <Track.DecreaseRepeatButton>
  127. <RepeatButton Command="ScrollBar.PageLeftCommand" Style="{DynamicResource ScrollBarPageButton}" />
  128. </Track.DecreaseRepeatButton>
  129. <Track.Thumb>
  130. <Thumb Margin="0,0,0,0" Style="{DynamicResource ScrollBarThumb}" />
  131. </Track.Thumb>
  132. <Track.IncreaseRepeatButton>
  133. <RepeatButton Command="ScrollBar.PageRightCommand" Style="{DynamicResource ScrollBarPageButton}" />
  134. </Track.IncreaseRepeatButton>
  135. </Track>
  136. <RepeatButton Grid.Column="3"
  137. Width="18"
  138. Command="ScrollBar.LineRightCommand"
  139. Content="M 0 0 L 4 4 L 0 8 Z"
  140. Style="{DynamicResource ScrollBarLineButton}" />
  141. </Grid>
  142. </ControlTemplate>
  143. <Style TargetType="{x:Type ScrollBar}">
  144. <Setter Property="Background" Value="{DynamicResource ScrollBackground}" />
  145. <Setter Property="SnapsToDevicePixels" Value="True" />
  146. <Setter Property="OverridesDefaultStyle" Value="true" />
  147. <Style.Triggers>
  148. <Trigger Property="Orientation" Value="Horizontal">
  149. <Setter Property="Width" Value="Auto" />
  150. <Setter Property="Height" Value="18" />
  151. <Setter Property="Template" Value="{DynamicResource HorizontalScrollBar}" />
  152. </Trigger>
  153. <Trigger Property="Orientation" Value="Vertical">
  154. <Setter Property="Width" Value="18" />
  155. <Setter Property="Height" Value="Auto" />
  156. <Setter Property="Template" Value="{DynamicResource VerticalScrollBar}" />
  157. </Trigger>
  158. </Style.Triggers>
  159. </Style>
  160. <Style TargetType="{x:Type ScrollViewer}">
  161. <Setter Property="Background" Value="{DynamicResource ScrollBackground}" />
  162. <Setter Property="OverridesDefaultStyle" Value="True" />
  163. <Setter Property="Template">
  164. <Setter.Value>
  165. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  166. <Grid>
  167. <Grid.ColumnDefinitions>
  168. <ColumnDefinition Width="*" />
  169. <ColumnDefinition Width="auto" />
  170. </Grid.ColumnDefinitions>
  171. <Grid.RowDefinitions>
  172. <RowDefinition Height="*" />
  173. <RowDefinition Height="auto" />
  174. </Grid.RowDefinitions>
  175. <ScrollContentPresenter Grid.Row="0" Grid.Column="0" />
  176. <ScrollBar Name="PART_VerticalScrollBar"
  177. Grid.Column="1"
  178. Background="{TemplateBinding Background}"
  179. Maximum="{TemplateBinding ScrollableHeight}"
  180. ViewportSize="{TemplateBinding ViewportHeight}"
  181. Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
  182. Value="{TemplateBinding VerticalOffset}" />
  183. <ScrollBar Name="PART_HorizontalScrollBar"
  184. Grid.Row="1"
  185. Background="{TemplateBinding Background}"
  186. Maximum="{TemplateBinding ScrollableWidth}"
  187. Orientation="Horizontal"
  188. ViewportSize="{TemplateBinding ViewportWidth}"
  189. Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
  190. Value="{TemplateBinding HorizontalOffset}" />
  191. </Grid>
  192. </ControlTemplate>
  193. </Setter.Value>
  194. </Setter>
  195. </Style>
  196. <Style x:Key="HorizontalMarketScrollBar" TargetType="{x:Type ScrollBar}">
  197. <Setter Property="Template">
  198. <Setter.Value>
  199. <ControlTemplate TargetType="{x:Type ScrollBar}">
  200. <Grid>
  201. <Grid.ColumnDefinitions>
  202. <ColumnDefinition Width="20" />
  203. <ColumnDefinition Width=" 1*" />
  204. <ColumnDefinition MaxWidth="20" />
  205. </Grid.ColumnDefinitions>
  206. <Border Grid.ColumnSpan="3"
  207. Background="{DynamicResource ScrollBackground}"
  208. CornerRadius="0" />
  209. <RepeatButton Grid.Column="0"
  210. Width="18"
  211. Command="ScrollBar.LineLeftCommand"
  212. Content="M 4 0 L 4 8 L 0 4 Z"
  213. Style="{DynamicResource ScrollBarLineButton}" />
  214. <Track Name="PART_Track"
  215. Grid.Column="1"
  216. Margin="0,1"
  217. IsDirectionReversed="False"
  218. Visibility="Collapsed">
  219. <Track.DecreaseRepeatButton>
  220. <RepeatButton Command="ScrollBar.PageLeftCommand" Style="{DynamicResource ScrollBarPageButton}" />
  221. </Track.DecreaseRepeatButton>
  222. <Track.Thumb>
  223. <Thumb Margin="0,0,0,0"
  224. BorderBrush="{DynamicResource CommonBorderBrush}"
  225. Style="{DynamicResource ScrollBarThumb}" />
  226. </Track.Thumb>
  227. <Track.IncreaseRepeatButton>
  228. <RepeatButton Command="ScrollBar.PageRightCommand" Style="{DynamicResource ScrollBarPageButton}" />
  229. </Track.IncreaseRepeatButton>
  230. </Track>
  231. <RepeatButton Grid.Column="2"
  232. Width="18"
  233. Command="ScrollBar.LineRightCommand"
  234. Content="M 0 0 L 4 4 L 0 8 Z"
  235. Style="{DynamicResource ScrollBarLineButton}" />
  236. </Grid>
  237. </ControlTemplate>
  238. </Setter.Value>
  239. </Setter>
  240. </Style>
  241. <Style x:Key="QuoteMarketStyle" TargetType="{x:Type ScrollViewer}">
  242. <Setter Property="OverridesDefaultStyle" Value="True" />
  243. <Setter Property="Template">
  244. <Setter.Value>
  245. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  246. <Grid>
  247. <Grid.ColumnDefinitions>
  248. <ColumnDefinition Width="Auto" />
  249. <ColumnDefinition Width="*" />
  250. <ColumnDefinition Width="Auto" />
  251. </Grid.ColumnDefinitions>
  252. <Grid.RowDefinitions>
  253. <RowDefinition Height="*" />
  254. <RowDefinition Height="auto" />
  255. </Grid.RowDefinitions>
  256. <!-- 占位Rectangle -->
  257. <Rectangle Grid.Column="0"
  258. Width="20"
  259. Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
  260. <Rectangle Grid.Column="2"
  261. Width="20"
  262. Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
  263. <ScrollBar Name="PART_VerticalScrollBar"
  264. Grid.Column="1"
  265. Maximum="{TemplateBinding ScrollableHeight}"
  266. ViewportSize="{TemplateBinding ViewportHeight}"
  267. Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
  268. Value="{TemplateBinding VerticalOffset}" />
  269. <ScrollBar Name="PART_HorizontalScrollBar"
  270. Grid.Column="0"
  271. Grid.ColumnSpan="3"
  272. Height="{TemplateBinding Height}"
  273. Maximum="{TemplateBinding ScrollableWidth}"
  274. Orientation="Horizontal"
  275. Style="{DynamicResource HorizontalMarketScrollBar}"
  276. ViewportSize="{TemplateBinding ViewportWidth}"
  277. Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
  278. Value="{TemplateBinding HorizontalOffset}" />
  279. <ScrollContentPresenter Grid.Row="0" Grid.Column="1" />
  280. </Grid>
  281. </ControlTemplate>
  282. </Setter.Value>
  283. </Setter>
  284. </Style>
  285. </ResourceDictionary>