fix(controls): Resolve vertical alignment issue in WPFUI TextBlock#1624
Closed
apachezy wants to merge 1 commit intolepoco:mainfrom
Closed
fix(controls): Resolve vertical alignment issue in WPFUI TextBlock#1624apachezy wants to merge 1 commit intolepoco:mainfrom
apachezy wants to merge 1 commit intolepoco:mainfrom
Conversation
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Please check the type of change your PR introduces:
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.
Many other layout‑sensitive situations where using
ui:TextBlockfeels “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
FontSizeand aLineHeightwhen 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
LineHeightsetting 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.
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