726 lines
36 KiB
XML
726 lines
36 KiB
XML
<ResourceDictionary
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||
<ResourceDictionary.MergedDictionaries>
|
||
<ResourceDictionary Source="RepeatButtonTransparent.xaml" />
|
||
</ResourceDictionary.MergedDictionaries>
|
||
|
||
<!-- 滑块默认样式 -->
|
||
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="ShadowSliderThumbTemplate">
|
||
<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="Effect" TargetName="grip" Value="{x:Null}" />
|
||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter Property="Stroke" TargetName="grip" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<ControlTemplate TargetType="{x:Type Slider}" x:Key="ShadowSliderVerticalTemplate">
|
||
<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>
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="*" />
|
||
<RowDefinition Height="40" />
|
||
</Grid.RowDefinitions>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
Margin="0,0,2,0"
|
||
Placement="Left"
|
||
Visibility="Collapsed"
|
||
Width="4"
|
||
x:Name="TopTick" />
|
||
<Border
|
||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||
BorderThickness="1"
|
||
CornerRadius="4"
|
||
Grid.Column="1"
|
||
Grid.Row="0"
|
||
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"
|
||
Grid.Row="0"
|
||
x:Name="PART_Track">
|
||
<Track.DecreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.DecreaseRepeatButton>
|
||
<Track.IncreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.IncreaseRepeatButton>
|
||
<Track.Thumb>
|
||
<Thumb
|
||
Focusable="False"
|
||
Height="20"
|
||
OverridesDefaultStyle="True"
|
||
Template="{StaticResource ShadowSliderThumbTemplate}"
|
||
VerticalAlignment="Top"
|
||
Width="22"
|
||
x:Name="Thumb" />
|
||
</Track.Thumb>
|
||
</Track>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="2"
|
||
Grid.Row="0"
|
||
Margin="2,0,0,0"
|
||
Placement="Right"
|
||
Visibility="Collapsed"
|
||
Width="4"
|
||
x:Name="BottomTick" />
|
||
<!-- 新增:简单的值显示TextBlock -->
|
||
<TextBlock
|
||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||
Grid.Column="1"
|
||
Grid.Row="1"
|
||
HorizontalAlignment="Center"
|
||
Margin="0,4,0,0"
|
||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}"
|
||
VerticalAlignment="Center"
|
||
x:Name="ValueDisplay">
|
||
<TextBlock.LayoutTransform>
|
||
<RotateTransform Angle="-90" />
|
||
</TextBlock.LayoutTransform>
|
||
</TextBlock>
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="2,5,0,5" />
|
||
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="0,5,2,5" />
|
||
<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="IsSelectionRangeEnabled" Value="True">
|
||
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||
</Trigger>
|
||
<!-- 新增:可以选择是否显示值 -->
|
||
<Trigger Property="Tag" Value="HideValue">
|
||
<Setter Property="Visibility" TargetName="ValueDisplay" Value="Collapsed" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<ControlTemplate TargetType="{x:Type Slider}" x:Key="ShadowSliderHorizontalTemplate">
|
||
<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>
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*" />
|
||
<ColumnDefinition Width="40" />
|
||
</Grid.ColumnDefinitions>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Row="0"
|
||
Height="4"
|
||
Margin="0,0,0,2"
|
||
Placement="Top"
|
||
Visibility="Collapsed"
|
||
x:Name="TopTick" />
|
||
<Border
|
||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||
BorderThickness="1"
|
||
CornerRadius="4"
|
||
Grid.Column="0"
|
||
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.Column="0"
|
||
Grid.Row="1"
|
||
x:Name="PART_Track">
|
||
<Track.DecreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.DecreaseRepeatButton>
|
||
<Track.IncreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.IncreaseRepeatButton>
|
||
<Track.Thumb>
|
||
<Thumb
|
||
Focusable="False"
|
||
Height="22"
|
||
OverridesDefaultStyle="True"
|
||
Template="{StaticResource ShadowSliderThumbTemplate}"
|
||
VerticalAlignment="Center"
|
||
Width="20"
|
||
x:Name="Thumb" />
|
||
</Track.Thumb>
|
||
</Track>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
Grid.Row="2"
|
||
Height="4"
|
||
Margin="0,2,0,0"
|
||
Placement="Bottom"
|
||
Visibility="Collapsed"
|
||
x:Name="BottomTick" />
|
||
<!-- 新增:简单的值显示TextBlock,放在滑块下方 -->
|
||
<TextBlock
|
||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||
Grid.Column="1"
|
||
Grid.Row="1"
|
||
HorizontalAlignment="Center"
|
||
Margin="4,0,0,0"
|
||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}"
|
||
VerticalAlignment="Center"
|
||
x:Name="ValueDisplay" />
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0" />
|
||
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2" />
|
||
<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="IsSelectionRangeEnabled" Value="True">
|
||
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<Style TargetType="{x:Type Slider}" x:Key="ShadowSliderStyle">
|
||
<Setter Property="Background" Value="Transparent" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
|
||
<Setter Property="Template" Value="{StaticResource ShadowSliderHorizontalTemplate}" />
|
||
<Style.Triggers>
|
||
<Trigger Property="Orientation" Value="Vertical">
|
||
<Setter Property="Template" Value="{StaticResource ShadowSliderVerticalTemplate}" />
|
||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||
</Trigger>
|
||
<!-- 触发器:当IsEnabled属性为False时,设置前景色为灰色 -->
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="TopLeft" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="BottomRight" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="Both" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
|
||
<ControlTemplate TargetType="{x:Type Thumb}" x:Key="DefaultSliderThumbTemplate">
|
||
<Grid
|
||
HorizontalAlignment="Center"
|
||
UseLayoutRounding="True"
|
||
VerticalAlignment="Center">
|
||
<Ellipse
|
||
Fill="{DynamicResource ControlBackgroundNormalBrush}"
|
||
Height="15"
|
||
StrokeThickness="1"
|
||
Width="15"
|
||
x:Name="grip">
|
||
<!--<Ellipse.Effect>
|
||
<DropShadowEffect
|
||
BlurRadius="12"
|
||
Opacity="0.4"
|
||
Color="{DynamicResource DarkShadowColor}" />
|
||
</Ellipse.Effect>-->
|
||
</Ellipse>
|
||
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="IsMouseOver" Value="True" />
|
||
<Trigger Property="IsDragging" Value="True">
|
||
<!--<Setter TargetName="grip" Property="Effect">
|
||
<Setter.Value>
|
||
<DropShadowEffect
|
||
BlurRadius="4"
|
||
Opacity="0.6"
|
||
ShadowDepth="3"
|
||
Color="{DynamicResource DarkShadowColor}" />
|
||
</Setter.Value>
|
||
</Setter>-->
|
||
</Trigger>
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter Property="Effect" TargetName="grip" Value="{x:Null}" />
|
||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter Property="Stroke" TargetName="grip" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
|
||
<!-- 轨道垂直默认样式 -->
|
||
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderVerticalTemplate">
|
||
<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>
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="*" />
|
||
<RowDefinition Height="40" />
|
||
</Grid.RowDefinitions>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
Margin="0,0,2,0"
|
||
Placement="Left"
|
||
Visibility="Collapsed"
|
||
Width="4"
|
||
x:Name="TopTick" />
|
||
<Border
|
||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||
BorderThickness="1"
|
||
CornerRadius="4"
|
||
Grid.Column="1"
|
||
Grid.Row="0"
|
||
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"
|
||
Grid.Row="0"
|
||
x:Name="PART_Track">
|
||
<Track.DecreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.DecreaseRepeatButton>
|
||
<Track.IncreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.IncreaseRepeatButton>
|
||
<Track.Thumb>
|
||
<Thumb
|
||
Focusable="False"
|
||
OverridesDefaultStyle="True"
|
||
Template="{StaticResource DefaultSliderThumbTemplate}"
|
||
VerticalAlignment="Top"
|
||
x:Name="Thumb" />
|
||
</Track.Thumb>
|
||
</Track>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="2"
|
||
Grid.Row="0"
|
||
Margin="2,0,0,0"
|
||
Placement="Right"
|
||
Visibility="Collapsed"
|
||
Width="4"
|
||
x:Name="BottomTick" />
|
||
<!-- 新增:简单的值显示TextBlock -->
|
||
<TextBlock
|
||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||
Grid.Column="1"
|
||
Grid.Row="1"
|
||
HorizontalAlignment="Center"
|
||
Margin="0,4,0,0"
|
||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}"
|
||
VerticalAlignment="Center"
|
||
x:Name="ValueDisplay">
|
||
<TextBlock.LayoutTransform>
|
||
<RotateTransform Angle="-90" />
|
||
</TextBlock.LayoutTransform>
|
||
</TextBlock>
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="2,5,0,5" />
|
||
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="0,5,2,5" />
|
||
<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="IsSelectionRangeEnabled" Value="True">
|
||
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||
</Trigger>
|
||
<!-- 新增:可以选择是否显示值 -->
|
||
<Trigger Property="Tag" Value="HideValue">
|
||
<Setter Property="Visibility" TargetName="ValueDisplay" Value="Collapsed" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<!-- 轨道水平默认样式 -->
|
||
<ControlTemplate TargetType="{x:Type Slider}" x:Key="SliderHorizontalTemplate">
|
||
<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>
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*" />
|
||
<ColumnDefinition Width="40" />
|
||
</Grid.ColumnDefinitions>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Row="0"
|
||
Height="4"
|
||
Margin="0,0,0,2"
|
||
Placement="Top"
|
||
Visibility="Collapsed"
|
||
x:Name="TopTick" />
|
||
<Border
|
||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||
BorderThickness="1"
|
||
CornerRadius="4"
|
||
Grid.Column="0"
|
||
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.Column="0"
|
||
Grid.Row="1"
|
||
x:Name="PART_Track">
|
||
<Track.DecreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.DecreaseRepeatButton>
|
||
<Track.IncreaseRepeatButton>
|
||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||
</Track.IncreaseRepeatButton>
|
||
<Track.Thumb>
|
||
<Thumb
|
||
Focusable="False"
|
||
Height="22"
|
||
OverridesDefaultStyle="True"
|
||
Template="{StaticResource DefaultSliderThumbTemplate}"
|
||
VerticalAlignment="Center"
|
||
Width="20"
|
||
x:Name="Thumb" />
|
||
</Track.Thumb>
|
||
</Track>
|
||
<TickBar
|
||
Fill="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
Grid.Row="2"
|
||
Height="4"
|
||
Margin="0,2,0,0"
|
||
Placement="Bottom"
|
||
Visibility="Collapsed"
|
||
x:Name="BottomTick" />
|
||
<!-- 新增:简单的值显示TextBlock,放在滑块下方 -->
|
||
<TextBlock
|
||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||
Grid.Column="1"
|
||
Grid.Row="1"
|
||
HorizontalAlignment="Center"
|
||
Margin="4,0,0,0"
|
||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}"
|
||
VerticalAlignment="Center"
|
||
x:Name="ValueDisplay" />
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0" />
|
||
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||
<Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2" />
|
||
<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="IsSelectionRangeEnabled" Value="True">
|
||
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||
<Setter Property="Foreground" TargetName="Thumb" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
|
||
<Style TargetType="{x:Type Slider}">
|
||
<Setter Property="Background" Value="Transparent" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
|
||
<Setter Property="Template" Value="{StaticResource SliderHorizontalTemplate}" />
|
||
<Style.Triggers>
|
||
<Trigger Property="Orientation" Value="Vertical">
|
||
<Setter Property="Template" Value="{StaticResource SliderVerticalTemplate}" />
|
||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||
</Trigger>
|
||
<!-- 触发器:当IsEnabled属性为False时,设置前景色为灰色 -->
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="TopLeft" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="BottomRight" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="TickPlacement" Value="Both" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||
</MultiTrigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
|
||
</ResourceDictionary> |