This repository was archived by the owner on Feb 25, 2026. It is now read-only.
[Feature] Extension to remove whitespace between TextBlock Runs #4656
MartinZikmund
started this conversation in
Ideas
Replies: 4 comments
|
Hello, 'MartinZikmund! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future! |
0 replies
|
I would be happy to implement this feature if it looks like a good fit :-) . |
0 replies
|
Thanks @MartinZikmund for highlighting the issue. Let's see what the other community members think and we can certainly move forward with this one. |
0 replies
|
@michael-hawker is this suitable for the toolkit? Thoughts? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the problem this feature would solve
While developing apps for high-school physics students, I noticed that writing
TextBlockcontent with multipleRunswith proper whitespace is a bit hard:For example to output "(1,6×10^19)" I have to do:
And this all has to be on a single line of XAML because whitespace between
Runsgenerates a space in the output. This may result in long, hard to read lines of code for multiple consecutiveRuns.Describe the solution
A solution similar to what is described in this blogpost with a small adjustment. Attached property
TrimWhitespaceRunsonTextBlockwould go throughRunsand for all which havestring.IsNullOrWhitespace(Text)it would set theirTexttostring.Empty. This way the runs stay there (in case someone the developer wanted to set them to something else later). It would also need to skipRunswhich have aBindingset for theTextproperty. A second attached property would allow preserving whitespaceRun.API
TextBox.TrimWhitespaceRunsPropertyRun.PreserveWhitespacePropertyThe above example would become:
Describe alternatives you've considered
Additional context & Screenshots
All reactions