Cómo aplicar un estilo de celda a la celda de DataGrid
Tengo los siguientesDataGrid
<DataGrid x:Name="cultureDataGrid"
Grid.Row="1"
CellStyle="{StaticResource DataGridCell}"
ItemsSource="{Binding Cultures,
NotifyOnSourceUpdated=True,
UpdateSourceTrigger=PropertyChanged,
Mode=TwoWay,
IsAsync=True}"
Style="{x:Null}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Code" Binding="{Binding Code}" IsReadOnly="True"/>
<DataGridTextColumn Header="Language" Binding="{Binding Language}" IsReadOnly="True"/>
<DataGridTextColumn Header="LocalName" Binding="{Binding LocalName}" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
Tengo el siguiente estilo de celda para cambiar el seleccionado.Backcolor
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="Background" Value="White"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Red"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
He intentado aplicar elCellStyle="{StaticResource DataGridCell}"
como se muestra arriba, y usandoDynamicResource
pero el recurso no se puede resolver. He importado el diccionario de recursos correcto ya que otros estilos están funcionando¿Qué estoy haciendo mal aquí?
Gracias por tu tiempo.