Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/SliderStyle.xaml
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

441 lines
23 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="RepeatButtonTransparent.xaml" />
</ResourceDictionary.MergedDictionaries>
<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" />
<!-- 滑块默认样式 -->
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="SliderThumbDefault">
<Grid
HorizontalAlignment="Center"
UseLayoutRounding="True"
VerticalAlignment="Center">
<Ellipse
Fill="{DynamicResource ControlBackgroundNormalBrush}"
Height="20"
StrokeThickness="1"
Width="20"
x:Name="grip">
<Ellipse.Effect>
<DropShadowEffect
BlurRadius="12"
Color="{DynamicResource DarkShadowColor}"
Opacity="0.4" />
</Ellipse.Effect>
</Ellipse>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True" />
<Trigger Property="IsDragging" Value="True">
<Setter Property="Effect" TargetName="grip">
<Setter.Value>
<DropShadowEffect
BlurRadius="4"
Color="{DynamicResource DarkShadowColor}"
Opacity="0.6"
ShadowDepth="3" />
</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}" />
<Setter Property="Effect" TargetName="grip" Value="{x:Null}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<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" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<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>
<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" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<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>
<!-- 轨道垂直默认样式 -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderVertical">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
x:Name="border">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<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
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1"
CornerRadius="4"
Grid.Column="1"
HorizontalAlignment="center"
Width="8"
x:Name="TrackBackground">
<Grid>
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="4"
Margin="-1"
VerticalAlignment="Bottom"
Width="8">
<Border.Height>
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="1">
<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}}" />
</MultiBinding>
</Border.Height>
</Border>
<Canvas Margin="-1,-6">
<Rectangle
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Visibility="Hidden"
Width="4.0"
x:Name="PART_SelectionRange" />
</Canvas>
</Grid>
</Border>
<Track Grid.Column="1" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb
Focusable="False"
Height="20"
OverridesDefaultStyle="True"
Template="{StaticResource SliderThumbDefault}"
VerticalAlignment="Top"
Width="22"
x:Name="Thumb" />
</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>
<Trigger Property="IsSelectionRangeEnabled" Value="True">
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Foreground" TargetName="Thumb" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<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" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<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="{DynamicResource SliderThumb.Disabled.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<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" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<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>
<!-- 轨道水平默认样式 -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderHorizontal">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
x:Name="border">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<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
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1"
CornerRadius="4"
Grid.Row="1"
Height="8"
VerticalAlignment="center"
x:Name="TrackBackground">
<Grid>
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="4"
Height="8"
HorizontalAlignment="Left"
Margin="-1">
<Border.Width>
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="0">
<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}}" />
</MultiBinding>
</Border.Width>
</Border>
<Canvas Margin="-6,-1">
<Rectangle
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Height="4.0"
Visibility="Hidden"
x:Name="PART_SelectionRange" />
</Canvas>
</Grid>
</Border>
<Track Grid.Row="1" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb
Focusable="False"
Height="22"
OverridesDefaultStyle="True"
Template="{StaticResource SliderThumbDefault}"
VerticalAlignment="Center"
Width="20"
x:Name="Thumb" />
</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>
<Trigger Property="IsSelectionRangeEnabled" Value="True">
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Foreground" TargetName="Thumb" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type Slider}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
<Setter Property="Template" Value="{StaticResource SliderHorizontal}" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Template" Value="{StaticResource SliderVertical}" />
</Trigger>
<!-- 触发器当IsEnabled属性为false时设置前景色为灰色 -->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>