Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Text Trimming support #9289

Open
Marv51 opened this issue Jan 26, 2024 · 0 comments
Open

Improved Text Trimming support #9289

Marv51 opened this issue Jan 26, 2024 · 0 comments
Labels
area-TextBlocks TextBlock, RichTextBlock feature proposal New feature proposal team-Controls Issue for the Controls team

Comments

@Marv51
Copy link
Contributor

Marv51 commented Jan 26, 2024

Proposal: Custom text trimming support

Summary

Introduce a way that developers can customize the text trimming of TextBox content easily.

Rationale

I'm displaying a folder path in my app. If the path is too long the end is trimmed and replaced with an ... (ellipse), because I set TextTrimming="CharacterEllipsis". That is a bad way to trim folder paths as the two relevant parts for users are the beginning and the end of a file path. They want to see what drive is this on and what file is it exactly.

Example:
"C:\Users\Marvin\Documents\Projects\Cool-Project\v1\Draft 2.txt"
this path should not be shown as "C:\Users\Marvin\Documents\Projects..." that not useful.
Instead something like "C:\Users...\Cool-Project\v1\Draft 2.txt" would be elegant and useful.

There are quite a few data-types that should have custom trimming to conserve the usefulness of a trimmed string:

  • File names
  • Folder paths
  • Addresses (esp. in countries with "[Street] [House number]" convention
  • Numbered items (Like "My Custom Label 1", "My Custom Label 2", ...
  • Dates

Scope

Important Notes

Developers should not have to include an ellipse in the Text property of a TextBlock and update the Text property continuely from a SizeChanged event.

One way to accomplish this would be to include the original string, the space available and the shorted string in the IsTextTrimmedChangedEventArgs, so that devs can subscribe to that event and manipulate the shortened string in the args.

A new property on TextBlock that allows devs to pass a trimming function would be another way to implement this functionality.

Open Questions

Could a few more trimming options also satisfy this need?

  • MiddleEllipsis (Trims characters in the middle of the string)
  • KeepNumbersEllipsis (Trims at the end, but keeps any number suffixes after the ellipsis)
  • StartWithEllipsis (Trims characters from the front)
  • Maybe something else?
@Marv51 Marv51 added the feature proposal New feature proposal label Jan 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 26, 2024
@codendone codendone added the area-TextBlocks TextBlock, RichTextBlock label Feb 15, 2024
@bpulliam bpulliam added team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TextBlocks TextBlock, RichTextBlock feature proposal New feature proposal team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants