How to set Datagrid row header background color

425 Views Asked by At

I have a datagrid that looks like this....

enter image description here

I need the area i highlight in purple need to set to background color (transparent) so that it becomes black. This part is a "Row Header" and the count is automatically added using DataGrid LoadingRow="OnLoadingRow"

    private void OnLoadingRow(object sender, DataGridRowEventArgs e)
    {
        e.Row.Header = (e.Row.GetIndex()+1).ToString();

        tickerListView.Items.MoveCurrentToLast();
        tickerListView.ScrollIntoView(tickerListView.Items.CurrentItem);
    }

However, i am not able to set the background color of this. How can i do it?

Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

If you use WPF then try this way:

<DataGrid>
    ...
    <DataGrid.Resources>
        <Style TargetType="Button" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}">
            <Setter Property="Background" Value="Transparent" />
        </Style>
    </DataGrid.Resources>
    ...
</DataGrid>