Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/SliderStyle.xaml

441 lines
23 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-20 12:10:35 +08:00
xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-31 20:12:24 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="RepeatButtonTransparent.xaml" />
</ResourceDictionary.MergedDictionaries>
2025-07-11 09:20:23 +08:00
2025-07-31 20:12:01 +08:00
<SolidColorBrush Color="#FFF0F0F0" x:Key="SliderThumb.Static.Background" />
<SolidColorBrush Color="#FFACACAC" x:Key="SliderThumb.Static.Border" />
<SolidColorBrush Color="#FFE5E5E5" x:Key="SliderThumb.Static.Foreground" />
<SolidColorBrush Color="#FFDCECFC" x:Key="SliderThumb.MouseOver.Background" />
<SolidColorBrush Color="#FF7Eb4EA" x:Key="SliderThumb.MouseOver.Border" />
<SolidColorBrush Color="#FFDAECFC" x:Key="SliderThumb.Pressed.Background" />
<SolidColorBrush Color="#FF569DE5" x:Key="SliderThumb.Pressed.Border" />
<SolidColorBrush Color="#FFF0F0F0" x:Key="SliderThumb.Disabled.Background" />
<SolidColorBrush Color="#FFD9D9D9" x:Key="SliderThumb.Disabled.Border" />
<SolidColorBrush Color="#FFE7EAEA" x:Key="SliderThumb.Track.Background" />
<SolidColorBrush Color="#FFD6D6D6" x:Key="SliderThumb.Track.Border" />
2025-07-11 09:20:23 +08:00
2025-07-31 20:12:01 +08:00
<!-- 滑块默认样式 -->
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbDefault">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Ellipse
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundNormalBrush}"
2025-07-31 20:12:01 +08:00
Height="20"
StrokeThickness="1"
Width="20"
x:Name="grip">
2025-07-11 09:20:23 +08:00
<Ellipse.Effect>
2025-07-31 20:12:01 +08:00
<DropShadowEffect
BlurRadius="12"
2025-08-12 23:08:54 +08:00
Color="{DynamicResource DarkShadowColor}"
2025-07-31 20:12:01 +08:00
Opacity="0.4" />
2025-07-11 09:20:23 +08:00
</Ellipse.Effect>
</Ellipse>
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True" />
<Trigger Property="IsDragging" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Effect" TargetName="grip">
<Setter.Value>
2025-07-31 20:12:01 +08:00
<DropShadowEffect
BlurRadius="4"
2025-08-12 23:08:54 +08:00
Color="{DynamicResource DarkShadowColor}"
2025-07-31 20:12:01 +08:00
Opacity="0.6"
ShadowDepth="3" />
2025-07-11 09:20:23 +08:00
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
2025-08-20 12:10:13 +08:00
<Setter Property="Effect" TargetName="grip" Value="{x:Null}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbVerticalLeft">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Path
Data="M 6,11 C6,11 0,5.5 0,5.5 0,5.5 6,0 6,0 6,0 18,0 18,0 18,0 18,11 18,11 18,11 6,11 6,11 z"
Fill="{StaticResource SliderThumb.Static.Background}"
Stretch="Fill"
Stroke="{StaticResource SliderThumb.Static.Border}"
x:Name="grip" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsDragging" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbVerticalRight">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Path
Data="M 12,11 C12,11 18,5.5 18,5.5 18,5.5 12,0 12,0 12,0 0,0 0,0 0,0 0,11 0,11 0,11 12,11 12,11 z"
Fill="{StaticResource SliderThumb.Static.Background}"
Stretch="Fill"
Stroke="{StaticResource SliderThumb.Static.Border}"
x:Name="grip" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsDragging" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<!-- 轨道垂直默认样式 -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderVertical">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
x:Name="border">
2025-07-11 09:20:23 +08:00
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<TickBar
Fill="{TemplateBinding Foreground}"
Grid.Column="0"
Margin="0,0,2,0"
Placement="Left"
Visibility="Collapsed"
Width="4"
x:Name="TopTick" />
<TickBar
Fill="{TemplateBinding Foreground}"
Grid.Column="2"
Margin="2,0,0,0"
Placement="Right"
Visibility="Collapsed"
Width="4"
x:Name="BottomTick" />
<Border
2025-08-12 23:08:54 +08:00
BorderBrush="{DynamicResource BorderNormalBrush}"
2025-07-31 20:12:01 +08:00
BorderThickness="1"
CornerRadius="4"
Grid.Column="1"
HorizontalAlignment="center"
Width="8"
x:Name="TrackBackground">
2025-07-11 09:20:23 +08:00
<Grid>
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="4"
Margin="-1"
VerticalAlignment="Bottom"
Width="8">
2025-07-11 09:20:23 +08:00
<Border.Height>
2025-08-20 12:10:13 +08:00
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="1">
2025-07-31 20:12:01 +08:00
<Binding
Mode="OneWay"
Path="Minimum"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="Maximum"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="Value"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="ActualHeight"
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
2025-07-11 09:20:23 +08:00
</MultiBinding>
</Border.Height>
</Border>
<Canvas Margin="-1,-6">
2025-07-31 20:12:01 +08:00
<Rectangle
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Visibility="Hidden"
Width="4.0"
x:Name="PART_SelectionRange" />
2025-07-11 09:20:23 +08:00
</Canvas>
</Grid>
</Border>
2025-07-31 20:12:01 +08:00
<Track Grid.Column="1" x:Name="PART_Track">
2025-07-11 09:20:23 +08:00
<Track.DecreaseRepeatButton>
2025-07-31 20:12:01 +08:00
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
2025-07-11 09:20:23 +08:00
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
2025-07-31 20:12:01 +08:00
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
2025-07-11 09:20:23 +08:00
</Track.IncreaseRepeatButton>
<Track.Thumb>
2025-07-31 20:12:01 +08:00
<Thumb
Focusable="False"
Height="20"
OverridesDefaultStyle="True"
Template="{StaticResource SliderThumbDefault}"
VerticalAlignment="Top"
Width="22"
x:Name="Thumb" />
2025-07-11 09:20:23 +08:00
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalLeft}" />
<Setter Property="Margin" TargetName="TrackBackground" Value="2,5,0,5" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalRight}" />
<Setter Property="Margin" TargetName="TrackBackground" Value="0,5,2,5" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsSelectionRangeEnabled" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsKeyboardFocused" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Foreground" TargetName="Thumb" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbHorizontalTop">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Path
Data="M 0,6 C0,6 5.5,0 5.5,0 5.5,0 11,6 11,6 11,6 11,18 11,18 11,18 0,18 0,18 0,18 0,6 0,6 z"
Fill="{StaticResource SliderThumb.Static.Background}"
SnapsToDevicePixels="True"
Stretch="Fill"
Stroke="{StaticResource SliderThumb.Static.Border}"
StrokeThickness="1"
UseLayoutRounding="True"
VerticalAlignment="Center"
x:Name="grip" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsDragging" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
2025-08-20 12:10:13 +08:00
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource SliderThumb.Disabled.Background}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbHorizontalBottom">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Path
Data="M 0,12 C0,12 5.5,18 5.5,18 5.5,18 11,12 11,12 11,12 11,0 11,0 11,0 0,0 0,0 0,0 0,12 0,12 z"
Fill="{StaticResource SliderThumb.Static.Background}"
SnapsToDevicePixels="True"
Stretch="Fill"
Stroke="{StaticResource SliderThumb.Static.Border}"
StrokeThickness="1"
UseLayoutRounding="True"
VerticalAlignment="Center"
x:Name="grip" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsDragging" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<!-- 轨道水平默认样式 -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderHorizontal">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
x:Name="border">
2025-07-11 09:20:23 +08:00
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<TickBar
Fill="{TemplateBinding Foreground}"
Grid.Row="0"
Height="4"
Margin="0,0,0,2"
Placement="Top"
Visibility="Collapsed"
x:Name="TopTick" />
<TickBar
Fill="{TemplateBinding Foreground}"
Grid.Row="2"
Height="4"
Margin="0,2,0,0"
Placement="Bottom"
Visibility="Collapsed"
x:Name="BottomTick" />
<Border
2025-08-12 23:08:54 +08:00
BorderBrush="{DynamicResource BorderNormalBrush}"
2025-07-31 20:12:01 +08:00
BorderThickness="1"
CornerRadius="4"
Grid.Row="1"
Height="8"
VerticalAlignment="center"
x:Name="TrackBackground">
2025-07-11 09:20:23 +08:00
<Grid>
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="4"
Height="8"
HorizontalAlignment="Left"
Margin="-1">
2025-07-11 09:20:23 +08:00
<Border.Width>
2025-08-20 12:10:13 +08:00
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="0">
2025-07-31 20:12:01 +08:00
<Binding
Mode="OneWay"
Path="Minimum"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="Maximum"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="Value"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding
Mode="OneWay"
Path="ActualWidth"
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
2025-07-11 09:20:23 +08:00
</MultiBinding>
</Border.Width>
</Border>
<Canvas Margin="-6,-1">
2025-07-31 20:12:01 +08:00
<Rectangle
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Height="4.0"
Visibility="Hidden"
x:Name="PART_SelectionRange" />
2025-07-11 09:20:23 +08:00
</Canvas>
</Grid>
</Border>
2025-07-31 20:12:01 +08:00
<Track Grid.Row="1" x:Name="PART_Track">
2025-07-11 09:20:23 +08:00
<Track.DecreaseRepeatButton>
2025-07-31 20:12:01 +08:00
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
2025-07-11 09:20:23 +08:00
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
2025-07-31 20:12:01 +08:00
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
2025-07-11 09:20:23 +08:00
</Track.IncreaseRepeatButton>
<Track.Thumb>
2025-07-31 20:12:01 +08:00
<Thumb
Focusable="False"
Height="22"
OverridesDefaultStyle="True"
Template="{StaticResource SliderThumbDefault}"
VerticalAlignment="Center"
Width="20"
x:Name="Thumb" />
2025-07-11 09:20:23 +08:00
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalTop}" />
<Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalBottom}" />
<Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsSelectionRangeEnabled" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsKeyboardFocused" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Foreground" TargetName="Thumb" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type Slider}">
2025-07-31 20:12:24 +08:00
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
2025-08-12 23:08:54 +08:00
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
2025-07-11 09:20:23 +08:00
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template" Value="{StaticResource SliderHorizontal}" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
2025-08-12 23:08:54 +08:00
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template" Value="{StaticResource SliderVertical}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<!-- 触发器当IsEnabled属性为false时设置前景色为灰色 -->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
2025-07-11 09:20:23 +08:00
</Style.Triggers>
</Style>
</ResourceDictionary>