Home > Blockchain >  how can i change color of row background ? wpf c#
how can i change color of row background ? wpf c#

Time:11-04

<DataGrid x ColumnWidth="*"
                  Background="#2c386c"
                  BorderThickness="0"
                  CanUserAddRows="False"
                  ItemsSource="{Binding CustomersList}"
                  SelectionChanged="customer_datagrid_SelectionChanged">

                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Background" Value="Transparent"/>
                        <Setter Property="Foreground" Value="#BCBEE0"/>
                        <Setter Property="Padding" Value="10,0,0,10"/>
                        <Setter Property="FontFamily" Value="Montserrat"/>
                        <Setter Property="FontSize" Value="15"/>
                    </Style>

                </DataGrid.ColumnHeaderStyle>


            </DataGrid>

I want to change the color of the background the datagrid and make it the same as the background color.

my datagrid view

CodePudding user response:

I think you are looking for is the RowStyle you can then targettype it to DataGridRow and set the background property to the color you need. Keep in mind the foreground might need to be changed as well since it will dark on dark.

RowHeaderStyle might also need to be addressed if you want the left side to be adjusted as well

<DataGrid.RowStyle>
    <Style TargetType="DataGridRow">
        <Setter Property="Background" Value="YourColor" />           
    </Style>
</DataGrid.RowStyle>
  • Related