简体   繁体   中英

How can I set the first DataGridCell's Background of a selected row in WPF

In WPF DataGrid's template of DataGridCell we can change the Background of selected cell.

But how to change the first cell's background color when a row is selected? Just like what the following picture shows.

在此处输入图片说明

You have to write your own cell style to highlight each cell background

<Window.Resources>    
    <Style x:Key="CellStyle" TargetType="DataGridCell">
        <Setter Property="Background" Value="Yellow" />
    </Style>
</Window.Resources>
<DataGrid x:Name="dataGrid" CellStyle="{StaticResource CellStyle}">
</DataGrid>

Could you please go through the following link

http://techiethings.blogspot.ch/2010/05/get-wpf-datagrid-row-and-cell.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM