tags:

views:

177

answers:

1

I would want to change the track a slider. Is there a way to do this?

<Track x:Name="PART_Track" Grid.Row="1">
    <Track.DecreaseRepeatButton>
      <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="{x:Static Slider.DecreaseLarge}"/>
    </Track.DecreaseRepeatButton>
    <Track.IncreaseRepeatButton>
     <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="{x:Static Slider.IncreaseLarge}"/>
    </Track.IncreaseRepeatButton>
    <Track.Thumb>
     <Thumb x:Name="Thumb" Style="{StaticResource HorizontalSliderThumbStyle}"/>
    </Track.Thumb>

+2  A: 

A track just handles the positioning of the Thumb and the Repeat buttons link text. The actual look of the track is in the template of the Slider.

To change the look of the "track" change the following area, PART_SelectionRange, in the control template

<ControlTemplate TargetType="{x:Type Slider}">
<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
 <Grid>
  <Grid.RowDefinitions>
   <RowDefinition Height="Auto"/>
   <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
   <RowDefinition Height="Auto"/>
  </Grid.RowDefinitions>
  <TickBar x:Name="TopTick" Height="4" Visibility="Collapsed" Grid.Row="0" Fill="{TemplateBinding Foreground}" Placement="Top"/>
  <TickBar x:Name="BottomTick" Height="4" Visibility="Collapsed" Grid.Row="2" Fill="{TemplateBinding Foreground}" Placement="Bottom"/>
  <Border Margin="5,0" VerticalAlignment="center" Height="20.0" Grid.Row="1" Background="{StaticResource HorizontalSliderTrackNormalBackground}" BorderBrush="{StaticResource HorizontalSliderTrackNormalBorder}" BorderThickness="1" CornerRadius="1">
   <Canvas Margin="-6,-1">
    <Rectangle x:Name="PART_SelectionRange" Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Stroke="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" StrokeThickness="1.0" Height="4.0" Visibility="visible"/>
   </Canvas>
  </Border>
  <Track x:Name="PART_Track" Grid.Row="1">
   <Track.DecreaseRepeatButton>
    <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="{x:Static Slider.DecreaseLarge}"/>
   </Track.DecreaseRepeatButton>
   <Track.IncreaseRepeatButton>
    <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="{x:Static Slider.IncreaseLarge}"/>
   </Track.IncreaseRepeatButton>
   <Track.Thumb>
    <Thumb x:Name="Thumb" Style="{StaticResource HorizontalSliderThumbStyle}"/>
   </Track.Thumb>
  </Track>
 </Grid>
</Border>