I have overrides DataGrid. Below are my code and XAML. How can I set style to change the DataGridCell background colour when the cell is selected?
<vw:DataGridExt
Grid.Row="1"
AlternatingRowBackground="LightGray"
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value,Mode=OneWay, IsAsync=True}"
Background="White"
AutoGenerateColumns="True"
IsReadOnly="True"
CanUserResizeRows="False"
ClipboardCopyMode="IncludeHeader"
CanUserSortColumns="True"
CanUserAddRows="False"
SelectionMode="Extended"/>
public class DataGridExt : DataGrid
{
public DataGridExt()
{
this.AutoGeneratedColumns += new EventHandler(DataGrid_AutoGeneratedColumns);
}
}
thanks in advance
shreesh chandra shukla
19-Jul-2013You have to provide a style for your DataGridCell
and set
SelectionUnit="Cell" for your DataGrid.