DataGrid for WPF and Silverlight Overview > DataGrid Features > DataGrid Appearance > Customizing Grid Appearance > Removing the Grid's Alternating Row Colors |
DataGrid for WPF appears with alternating row colors by default. Alternating row colors are when alternate lines appear in a different color than the base color of the grid. This is helpful so that rows are easier to follow across the grid, but if you choose you can make the appearance of the grid uniform by removing the alternating row colors.
At Design Time
To remove alternating row colors and set it so all rows appear white, complete the following steps:
In XAML
To remove alternating row colors and set it so all rows appear white, add RowBackground="White" AlternatingRowBackground="White" to the <c1:C1DataGrid> tag so that it appears similar to the following:
<c1:C1DataGrid Name="c1datagrid1" Height="180" Width="250" RowBackground="White" AlternatingRowBackground="White" />
In Code
To remove alternating row colors and set it so all rows appear white, add the following code to your project:
Visual Basic |
Copy Code
|
---|---|
Me.C1DataGrid1.RowBackground = New System.Windows.Media.SolidColorBrush(Colors.White) Me.C1DataGrid1.AlternatingRowBackground = New System.Windows.Media.SolidColorBrush(Colors.White) |
C# |
Copy Code
|
---|---|
this.c1DataGrid1.RowBackground = new System.Windows.Media. SolidColorBrush(Colors.White); this.c1DataGrid1.AlternatingRowBackground = new System.Windows.Media. SolidColorBrush(Colors.White); |
What You've Accomplished
Run the application and observe that all rows in the grid now appear white.