Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coloring Gridlines in WPF Datagrid

How can I set the color of the gridlines of a wpf datagrid? I can hide these lines with the property GridLinesVisibility, but I don't know how to color them. I tried it with the Borderbrush of rows and cells but I didn't succeed.

like image 656
Hulda Avatar asked Feb 22 '11 10:02

Hulda


2 Answers

You have the Properties HorizontalGridLinesBrush and VerticalGridLinesBrush

Example

<DataGrid HorizontalGridLinesBrush="Green"
          VerticalGridLinesBrush="Red"
          ...>
like image 58
Fredrik Hedblad Avatar answered Nov 11 '22 18:11

Fredrik Hedblad


You can change the VerticalGridLinesBrush and HorizontalGridLinesBrush properties of the Datagrid

 <Window.Resources>
       <SolidColorBrush x:Key="RedGridLine" Color="#FFFF4444" />
       <SolidColorBrush x:Key="BlueGridLine" Color="#554444FF"/>
    </Window.Resources>

<my:DataGrid VerticalGridLinesBrush="{StaticResource RedGridLine}"
        HorizontalGridLinesBrush="{StaticResource BlueGridLine}" >

For more

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0202b0dd-38d9-4ad7-8576-d115922aeeec/

http://www.c-sharpcorner.com/UploadFile/dpatra/1803/

like image 11
biju Avatar answered Nov 11 '22 17:11

biju