選択したセルのスタイルを WPF DataGrid コントロールで変更しようとしています。
DataGridCell
スタイリングとはどう違いDataGridRow
ますか?以下のさまざまな組み合わせを試しましたが、すべて機能します。ただし、スタイルを設定する必要があるのはまたはのいずれか DataGridCell
だけのようですDataGridRow
。
両方を持つ目的は何ですか?これは、私が彼らの目的を誤解していることを示しています。
スタイルDataGridCell
: (自分のコードでは、デフォルトから色を変更します)
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
</Style.Triggers>
</Style>
スタイルDataGridRow
: (自分のコードでは、デフォルトから色を変更します)
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
</Style.Triggers>
</Style>