Skip to content

Fix DataGrid row/cell colors not adapting to theme#11

Merged
scanfing merged 1 commit intomainfrom
copilot/fix-datagrid-header-color
Apr 28, 2026
Merged

Fix DataGrid row/cell colors not adapting to theme#11
scanfing merged 1 commit intomainfrom
copilot/fix-datagrid-header-color

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

WPF's DataGridRow and DataGridCell have their own system default templates and do not inherit Background/Foreground from the parent DataGrid, so rows and cells stayed white/black regardless of theme.

Changes

  • Added RowStyle to ThemedDataGrid: binds Background/Foreground to PanelBackgroundBrush/WindowForegroundBrush; selected and hovered rows use AccentBrushSubtle
  • Added CellStyle to ThemedDataGrid: transparent background (row controls the fill), Foreground bound to WindowForegroundBrush, selected cells render white text with transparent border to avoid the default blue selection highlight clashing with row-level highlight
<Setter Property="RowStyle">
    <Setter.Value>
        <Style TargetType="DataGridRow">
            <Setter Property="Background" Value="{DynamicResource PanelBackgroundBrush}" />
            <Setter Property="Foreground" Value="{DynamicResource WindowForegroundBrush}" />
            ...
        </Style>
    </Setter.Value>
</Setter>
<Setter Property="CellStyle">
    <Setter.Value>
        <Style TargetType="DataGridCell">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Foreground" Value="{DynamicResource WindowForegroundBrush}" />
            <Setter Property="BorderBrush" Value="Transparent" />
            ...
        </Style>
    </Setter.Value>
</Setter>

@scanfing scanfing marked this pull request as ready for review April 28, 2026 08:44
@scanfing scanfing merged commit 46c6c66 into main Apr 28, 2026
@scanfing scanfing deleted the copilot/fix-datagrid-header-color branch April 28, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants