Files
ShrlAlgoToolkit/WPFluent/Controls/Slider/Slider.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

190 lines
9.0 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type RepeatButton}" x:Key="UiSliderButtonStyle">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Thumb}" x:Key="UiSliderThumbStyle">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="20" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorAttentionBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="{DynamicResource ControlSolidFillColorDefaultBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="16">
<Ellipse
Fill="{TemplateBinding Foreground}"
Height="12"
Stroke="Transparent"
StrokeThickness="0"
Width="12"
x:Name="Ellipse" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Template when the orientation of the Slider is Horizontal. -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="UiHorizontalSlider">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TickBar
Fill="{DynamicResource ControlStrongFillColorDefaultBrush}"
Grid.Row="0"
Height="6"
Placement="Top"
SnapsToDevicePixels="True"
Visibility="Collapsed"
x:Name="TopTick" />
<Border
Background="{DynamicResource ControlStrongFillColorDefaultBrush}"
BorderThickness="0"
CornerRadius="2"
Grid.Row="1"
Height="4"
Margin="0"
x:Name="TrackBackground" />
<Track Grid.Row="1" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="Slider.DecreaseLarge" Style="{StaticResource UiSliderButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource UiSliderThumbStyle}" x:Name="Thumb" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="Slider.IncreaseLarge" Style="{StaticResource UiSliderButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>
<TickBar
Fill="{DynamicResource ControlStrongFillColorDefaultBrush}"
Grid.Row="2"
Height="6"
Placement="Bottom"
SnapsToDevicePixels="True"
Visibility="Collapsed"
x:Name="BottomTick" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="TrackBackground" Value="{DynamicResource ControlStrongFillColorDefaultBrush}" />
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource SystemFillColorAttentionBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- Template when the orientation of the Slider is Vertical. -->
<ControlTemplate TargetType="{x:Type Slider}" x:Key="UiVerticalSlider">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TickBar
Fill="{DynamicResource ControlStrongFillColorDefaultBrush}"
Placement="Left"
SnapsToDevicePixels="True"
Visibility="Collapsed"
Width="6"
x:Name="TopTick" />
<Border
Background="{DynamicResource ControlStrongFillColorDefaultBrush}"
BorderThickness="0"
CornerRadius="2"
Grid.Column="1"
Margin="0"
Width="4"
x:Name="TrackBackground" />
<Track Grid.Column="1" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="Slider.DecreaseLarge" Style="{StaticResource UiSliderButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource UiSliderThumbStyle}" x:Name="Thumb" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="Slider.IncreaseLarge" Style="{StaticResource UiSliderButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>
<TickBar
Fill="{DynamicResource ControlStrongFillColorDefaultBrush}"
Grid.Column="2"
Placement="Right"
SnapsToDevicePixels="True"
Visibility="Collapsed"
Width="6"
x:Name="BottomTick" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="TrackBackground" Value="{DynamicResource ControlStrongFillColorDefaultBrush}" />
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource SystemFillColorAttentionBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type Slider}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="MinWidth" Value="104" />
<Setter Property="MinHeight" Value="21" />
<Setter Property="Template" Value="{StaticResource UiHorizontalSlider}" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="MinWidth" Value="21" />
<Setter Property="MinHeight" Value="104" />
<Setter Property="Template" Value="{StaticResource UiVerticalSlider}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>