Reputation: 473
I have a slider that is on a white background. The default knob color is white for a metro slider. Is there a simple way to change the color of it?
Upvotes: 0
Views: 1661
Reputation: 5633
If you want to manually control the style of the slider, you need to update select the Slider then use the Format->Edit Style->Edit Copy command on the toolbar.
You will need to find the following in the Style XAML...
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
</ControlTemplate>
</Setter.Value>
You can then set the background colors here. This creates a single style that can be used. Be aware of two things... 1. You may want to look at the VisualStateManager states and see how the colors are changed as the slider is used and make adjustments there as necessary 2. By going this route, you are breaking the ability of the slider to adjust to the user selecting different device themes. For example, if the user selects a dark theme and you are reflecting some of that using the built-in templates, you can get controls that will not look good with a given theme. A simple example (though not applicable since it sounds like you are setting the page background color explicitly) is if someone changed the slider color to black using this approach, not accounting for the fact that they are developing using the light theme and the user may be using the dark theme. Hopefully that makes sense.
Upvotes: 1