user3428422
user3428422

Reputation: 4570

WPF Modifying scrollbar in DataGrid issue

I am trying to style the scrollbars in my datagrids using app.xaml (want it to be global across the app)

My code I have done is

  <Style TargetType="{x:Type DataGrid}">
     <Setter Property="ScrollViewer.Background"  Value="LightBlue"></Setter>
     <Setter Property="ScrollViewer.Foreground" Value="LightGray"></Setter>
  </Style>

However, it doesn't work, is there anything I have missed?

Cheers

Upvotes: 0

Views: 80

Answers (1)

Heena
Heena

Reputation: 8654

Try this

 <Style TargetType="{x:Type DataGrid}">
        <Style.Resources>
         <Style TargetType="ScrollViewer">
            <Setter Property="Background" Value="LightBlue"/>
            <Setter Property="TextElement.Foreground" Value="LightGray"/>
        </Style>
        </Style.Resources>                       
 </Style>

Note : for scrollbar change target type <Style TargetType="Scrollbar">

Upvotes: 2

Related Questions