Slider.xaml 5.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Style x:Key="SliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
  3. <Setter Property="OverridesDefaultStyle" Value="true" />
  4. <Setter Property="IsTabStop" Value="false" />
  5. <Setter Property="Focusable" Value="false" />
  6. <Setter Property="Template">
  7. <Setter.Value>
  8. <ControlTemplate TargetType="{x:Type RepeatButton}">
  9. <Rectangle Fill="Transparent" />
  10. </ControlTemplate>
  11. </Setter.Value>
  12. </Setter>
  13. </Style>
  14. <Style x:Key="HorizontalSliderThumbStyle" TargetType="{x:Type Thumb}">
  15. <Setter Property="Focusable" Value="false" />
  16. <Setter Property="OverridesDefaultStyle" Value="true" />
  17. <Setter Property="Height" Value="20" />
  18. <Setter Property="Width" Value="20" />
  19. <Setter Property="Foreground" Value="Gray" />
  20. <Setter Property="Template">
  21. <Setter.Value>
  22. <ControlTemplate TargetType="{x:Type Thumb}">
  23. <Ellipse
  24. Fill="#31b0d5"
  25. Stroke="Gray"
  26. StrokeThickness="0.5" />
  27. </ControlTemplate>
  28. </Setter.Value>
  29. </Setter>
  30. </Style>
  31. <Style x:Key="VolumeSliderStyle" TargetType="Slider">
  32. <Setter Property="Cursor" Value="Hand" />
  33. <Setter Property="HorizontalAlignment" Value="Right" />
  34. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
  35. <Setter Property="Background" Value="Transparent" />
  36. <Setter Property="Foreground" Value="#FFC4C4C4" />
  37. <Setter Property="IsSelectionRangeEnabled" Value="True" />
  38. <Setter Property="SelectionStart" Value="0" />
  39. <Setter Property="SelectionEnd" Value="{Binding Value, RelativeSource={RelativeSource Mode=Self}}" />
  40. <Setter Property="Width" Value="230" />
  41. <Setter Property="Template">
  42. <Setter.Value>
  43. <ControlTemplate TargetType="{x:Type Slider}">
  44. <Border
  45. Background="{TemplateBinding Background}"
  46. BorderBrush="{TemplateBinding BorderBrush}"
  47. BorderThickness="{TemplateBinding BorderThickness}"
  48. SnapsToDevicePixels="true">
  49. <Grid>
  50. <Border
  51. x:Name="TrackBackground"
  52. Width="{TemplateBinding Width}"
  53. Height="8.0"
  54. Margin="5,0"
  55. VerticalAlignment="Center"
  56. Background="#D3D3D3"
  57. CornerRadius="2">
  58. <Canvas>
  59. <Border
  60. x:Name="PART_SelectionRange"
  61. Margin="-10,0,0,0"
  62. Background="#31b0d5"
  63. CornerRadius="2" />
  64. </Canvas>
  65. </Border>
  66. <Track x:Name="PART_Track">
  67. <Track.DecreaseRepeatButton>
  68. <RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource SliderRepeatButtonStyle}" />
  69. </Track.DecreaseRepeatButton>
  70. <Track.IncreaseRepeatButton>
  71. <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource SliderRepeatButtonStyle}" />
  72. </Track.IncreaseRepeatButton>
  73. <Track.Thumb>
  74. <Thumb x:Name="Thumb" Style="{StaticResource HorizontalSliderThumbStyle}" />
  75. </Track.Thumb>
  76. </Track>
  77. </Grid>
  78. </Border>
  79. <ControlTemplate.Triggers>
  80. <Trigger Property="IsSelectionRangeEnabled" Value="True">
  81. <Setter TargetName="PART_SelectionRange" Property="Visibility" Value="Visible" />
  82. </Trigger>
  83. <Trigger Property="Orientation" Value="Horizontal">
  84. <Setter TargetName="PART_SelectionRange" Property="Height" Value="8" />
  85. </Trigger>
  86. <Trigger Property="Orientation" Value="Vertical">
  87. <Setter TargetName="TrackBackground" Property="Width" Value="8" />
  88. <Setter TargetName="TrackBackground" Property="Height" Value="150" />
  89. <Setter TargetName="PART_SelectionRange" Property="Width" Value="8" />
  90. <Setter TargetName="PART_SelectionRange" Property="Margin" Value="0,9,0,0" />
  91. </Trigger>
  92. </ControlTemplate.Triggers>
  93. </ControlTemplate>
  94. </Setter.Value>
  95. </Setter>
  96. </Style>
  97. </ResourceDictionary>