<!--Slider 样式--> <Style x:Key="StyleForRepeatButton" TargetType="{x:Type RepeatButton}"> <Style.Setters> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="LightGreen" Offset="0"/> <GradientStop Color="Yellow" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="Height" Value="10"/> <Setter Property="BorderBrush" Value="Transparent"/> <Setter Property="Focusable" Value="False"/> </Style.Setters> <Style.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="LightBlue" Offset="0"/> <GradientStop Color="SkyBlue" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> <ControlTemplate x:Key="tmpThumb" TargetType="{x:Type Thumb}"> <Ellipse Name="e" Width="13" MinHeight="20" Fill="Blue" Cursor="Hand"/> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="e" Property="Fill" Value="Red"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> <ControlTemplate x:Key="tmpSlider" TargetType="{x:Type Slider}"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto" MinHeight="25"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <TickBar x:Name="top" Fill="Magenta" Grid.Row="0" HorizontalAlignment="Stretch" Placement="Top" Height="8" Visibility="Collapsed"/> <Track x:Name="PART_Track" Grid.Row="1" HorizontalAlignment="Stretch"> <Track.IncreaseRepeatButton> <RepeatButton Style="{StaticResource StyleForRepeatButton}" Command="Slider.IncreaseLarge"/> </Track.IncreaseRepeatButton> <Track.DecreaseRepeatButton> <RepeatButton Style="{StaticResource StyleForRepeatButton}" Command="Slider.DecreaseLarge"/> </Track.DecreaseRepeatButton> <Track.Thumb> <Thumb Height="20" Template="{StaticResource tmpThumb}"/> </Track.Thumb> </Track> <TickBar x:Name="Bottom" Grid.Row="2" Fill="Magenta" HorizontalAlignment="Stretch" Visibility="Collapsed" Placement="Bottom" Height="8"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="TickPlacement" Value="TopLeft"> <Setter TargetName="top" Property="Visibility" Value="Visible"/> </Trigger> <Trigger Property="TickPlacement" Value="BottomRight"> <Setter Property="Visibility" TargetName="Bottom" Value="Visible"/> </Trigger> <Trigger Property="TickPlacement" Value="Both"> <Setter TargetName="top" Property="Visibility" Value="Visible"/> <Setter TargetName="Bottom" Property="Visibility" Value="Visible"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>