Skip to content

fix(DataGrid): add VerticalContentAlignment/HorizontalContentAlignment bindings to DataGridCell ContentPresenter#4069

Open
JyslaFancy wants to merge 1 commit into
MaterialDesignInXAML:masterfrom
JyslaFancy:fix/3999-datagridcell-vertical-content-alignment
Open

fix(DataGrid): add VerticalContentAlignment/HorizontalContentAlignment bindings to DataGridCell ContentPresenter#4069
JyslaFancy wants to merge 1 commit into
MaterialDesignInXAML:masterfrom
JyslaFancy:fix/3999-datagridcell-vertical-content-alignment

Conversation

@JyslaFancy

Copy link
Copy Markdown

Description

Fixes #3999 — Vertical Centering of DataGrid Cells producing extra border lines.

Root cause

The ControlTemplate's ContentPresenter was missing bindings for and .

When users wanted to vertically center cell content, they would set on the DataGridCell style. This caused the DataGridCell itself to shrink vertically within its row, exposing DataGrid horizontal grid lines as unwanted border artifacts above and below the cell.

The correct property to use is — but even that had no effect because the ContentPresenter lacked the TemplateBinding.

Fix

Added and to the ContentPresenter, matching the pattern already used in (line 322 of the same file).

Before

After

Usage

Users can now vertically center cell content correctly:

…t to DataGridCell ContentPresenter

The MaterialDesignDataGridCell ControlTemplate's ContentPresenter was missing
bindings for VerticalContentAlignment and HorizontalContentAlignment. This meant
users could not properly vertically center cell content using the standard
VerticalContentAlignment property, leading them to misuse VerticalAlignment
instead — which caused the DataGridCell to shrink within its row, exposing
DataGrid grid lines as unwanted 'extra border lines' above and below the cell.

Fix: Added HorizontalAlignment and VerticalAlignment TemplateBindings to the
ContentPresenter, matching the pattern already used in DataGridColumnHeader.

Fixes MaterialDesignInXAML#3999
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.

Vertical Centering of DataGrid Cells

1 participant