2014-03-28 72 views
0

以下是代碼,我必須在移動滑塊時更改軌道的顏色。 請給我一個解決方案如何更改滑塊中的軌道顏色wpf

<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 CustomThumbForSlider}" Background="Black"/> 
          </Track.Thumb> 
         </Track> 

回答

0

你應該做在你SliderRepeatButtonStyle風格。 背景屬性定義了軌道內側部分的顏色,BorderBrush屬性定義了軌道邊框的顏色。

<Style x:Key="SliderRepeatButtonStyle" TargetType="RepeatButton"> 
    <Setter Property="SnapsToDevicePixels" Value="true" /> 
    <Setter Property="OverridesDefaultStyle" Value="true" /> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="RepeatButton"> 
       <Border SnapsToDevicePixels="True" Background="Red" BorderThickness="1" BorderBrush="OrangeRed" Height="3"/> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style>