ComponentOne DataGrid for WPF and Silverlight
DataGrid for WPF and Silverlight Overview / DataGrid Features / DataGrid Appearance / Customizing Grid Appearance / Removing the Grid's Alternating Row Colors
In This Topic
    Removing the Grid's Alternating Row Colors
    In This Topic

    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:

    1. Click the C1DataGrid control once to select it.
    2. Navigate to the Properties window and click the drop-down arrow next to the RowBackground property.
    3. Click the drop-down arrow in the box the hex code appears in, and choose White.
    4. Navigate to the Properties window and click the drop-down arrow next to the AlternatingRowBackground property.
    5. Click the drop-down arrow in the box the hex code appears in, and choose White.

    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.