annonymously
annonymously

Reputation: 4708

How to increase the thickness of a `Slider` control

I have a slider control in my grid:

<Slider x:Name="MainSlider"
        Margin="659,145,417,146"
        Grid.Row="1"
        Orientation="Vertical"
        SmallChange="1"
        RenderTransformOrigin="0.0799999982118607,0.5"/>

I want it to be wider though, so that the whole bar is stretched out.

I've gone through the properties and Width doesn't actually change the thickness of the slider itself, just the frame.

How can I make the actual Slider thicker?

Upvotes: 3

Views: 4782

Answers (3)

CodyF
CodyF

Reputation: 5227

If you make a template from a copy of the slider template:

Right-Click Slider->"Edit Template" -> "Edit a Copy"

Then you can change the TrackBackground and PART_SelectionRange WIDTH to whatever you want. They were "4.0" by default for my case:

<Border x:Name="TrackBackground"
        Grid.Column="1"
        Width="XX.X"
        Margin="0,5"
        HorizontalAlignment="center"
        Background="{StaticResource HorizontalSliderTrackNormalBackground}"
        BorderBrush="{StaticResource VerticalSliderTrackNormalBorder}"
        BorderThickness="1"
        CornerRadius="1">
    <Canvas Margin="-1,-6">
        <Rectangle x:Name="PART_SelectionRange"
                   Width="XX.X"
                   Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
                   Stroke="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"
                   StrokeThickness="1.0"
                   Visibility="Hidden" />
    </Canvas>
</Border>

Upvotes: 0

ChrisF
ChrisF

Reputation: 137148

You will probably need to define your own style. You can copy the default style (using Expression Blend for example) and tweak the individual component values.

Use the "Edit Style" option to take a copy of the template and then work on that.

There's more information on MSDN

Upvotes: 3

Related Questions