I always set the background of the rows on a data grid with a converter, so to see the background, I have to set SystemColors.InactiveSelectionHighlightBrushKey to "Trasparent".
By the momento I am using this code in avery data grid that I have in my views:
<DataGrid Name="dgdMyDataGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,0,5,5" Grid.Row="2" ItemsSource="{Binding MyObservableCollectionInViewModel}" SelectedIndex="{Binding MySelectedIndex, Mode=TwoWay}"><DataGrid.Resources><SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent"/><SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/><SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/><SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Black"/></DataGrid.Resources></Datagrid>
I set alays the Datagrid.Resources, but I would like to avoid to set this in every data grid, so I would like to use a resources dictionary to use always the same configuration. I am trying something like this:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Style TargetType="{x:Type DataGrid}"><Style.Resources><!--????--></Style.Resources></Style></ResourceDictionary>
But I don't know really hoe to set this properties. I can use a resource dictionary in this case? and if I can do it, How I could do it?
Thank so much.