Skip to content

fix(controls): Resolve vertical alignment issue in WPFUI TextBlock#1624

Closed
apachezy wants to merge 1 commit intolepoco:mainfrom
apachezy:fix/textblock-ver-align
Closed

fix(controls): Resolve vertical alignment issue in WPFUI TextBlock#1624
apachezy wants to merge 1 commit intolepoco:mainfrom
apachezy:fix/textblock-ver-align

Conversation

@apachezy
Copy link
Copy Markdown
Contributor

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

Currently, the WPFUI TextBlock offers rich styling and typography that perfectly matches the Fluent design system and automatically adapts to theme changes, making it a must‑use control in modern UI development. However, it has long suffered from a seemingly odd issue where it “cannot be vertically centered.” This causes misalignment in many scenarios, such as In the TitleBar, header text does not align vertically with icons.

TextBlock-ver-NotAlign

Many other layout‑sensitive situations where using ui:TextBlock feels “difficult to control.”

As a result, developers who care about precise UI experience often abandon WPFUI TextBlock in favor of the built‑in WPF TextBlock.

After investigation, the problem was traced to the fact that WPFUI TextBlock applies both a FontSize and a LineHeight when setting typography. Line‑height behaves differently across fonts and DPIs, and its calculation is not fixed relative to font size. Forcing both together breaks vertical alignment in many layout contexts.

Issue Number: #1617

What is the new behavior?

Removed the automatic LineHeight setting from the TextBlock’s typography styling. This allows the control to rely on natural text layout metrics, restoring correct vertical alignment in all common use cases.

  • In the TitleBar, header text now aligns vertically with icons.

    TextBlock-ver-Align
  • General developer experience when using WPFUI TextBlock is improved — no more “hard‑to‑control” vertical alignment issues.

  • The control retains all its Fluent styling and theme‑adaptive behavior.

  • Fixed The title is not aligned. #1617

Other information

@github-actions github-actions Bot added controls Changes to the appearance or logic of custom controls. styles Topic is related to styles PR Pull request release labels Dec 27, 2025
@apachezy apachezy closed this Jan 1, 2026
@apachezy apachezy deleted the fix/textblock-ver-align branch January 6, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controls Changes to the appearance or logic of custom controls. PR Pull request release styles Topic is related to styles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The title is not aligned.

1 participant