10

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 2

11
<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.

Sign up to request clarification or add additional context in comments.

Comments

7

Set the ScrollViewer style equal to a style that you build separately. Here are two links where the authors create a style first, and then apply said style to a wpf control after that:

http://www.codeproject.com/Articles/37366/Styling-A-ScrollViewer-Scrollbar-In-WPF.aspx

http://www.eggheadcafe.com/tutorials/aspnet/f51ddf8c-5227-4f1b-a5df-ec3d1b3439ca/styling-the-wpf-scrollviewer.aspx

1 Comment

super out dated

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.