Change background color of ScrollBar in ScrollViewer wpf

Viewed 32669

I know how to change the background color of a scrollbar:

<ScrollBar Height="27" Margin="36,96,12,0" Name="scrollBar1" Background="Red"></ScrollBar>

here is the picture with my red background: enter image description here

How could I do the same thing with ScrollViewer? I have a grid inside my ScrollViewer and if I change the properties of ScrollViewer it seem to change the properties of the content inside my grid.

<ScrollViewer>


    <Grid Name="Parent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
             ....
             ....
             ... etc

that produces:

enter image description here

with the content of my grid named Parent on the left. How could I place a red background on this ScrollViewer?

2 Answers
<Window.Resources>
    <Style TargetType="ScrollBar">
        <Setter Property="Background" Value="White"/>
    </Style>
</Window.Resources>

In the above code, the programmer can give any color value he/she wants to set. For Eg, I have set the background color of my scrollbar to White.

Related