Open Symbai opened 11 months ago
Isn't it supported already? https://github.com/AvaloniaUI/Avalonia/pull/7322
works already
<TextBlock Text="Hello world from long text" MaxWidth="100">
<TextBlock.TextTrimming>
<TextLeadingPrefixTrimming>
<x:Arguments>
<system:String> ▲ ▲ ▲ </system:String>
<system:Int32>3</system:Int32>
</x:Arguments>
</TextLeadingPrefixTrimming>
</TextBlock.TextTrimming>
</TextBlock>
Jesus, this looks so "over complicated ". Instead of a single line we have now 8 lines to write... for EVERY single textblock. Also in your example it trims at the middle of text. How to trim at the beginning? I dont even understand how this works. Is there any documentation?!
Jesus, this looks so "over complicated ". Instead of a single line we have now 8 lines to write... for EVERY single textblock.
I think you can define a resource and then use it: <TextBlock TextTrimming="{StaticResource MyTrimming}" />
Also in your example it trims at the middle of text. How to trim at the beginning?
I think the second argument corresponds to the length of the prefix to keep, so you would set it to 0
instead of 3
.
Not sure if there are docs for this yet. You can see the docs in this class:
You're probably looking for this:
So I guess you can do <TextBlock TextTrimming="{x:Static TextTrimming.LeadingCharacterEllipsis}" />
@Symbai that was only one possible syntax if you need trimming in middle of the string and want pure XAML.
other working solutions:
... We may want to extend docs here, so I transferred this issue.
So I guess you can do
<TextBlock TextTrimming="{x:Static TextTrimming.LeadingCharacterEllipsis}" />
That is pretty cool, thank you. I hope the docs will show this example. While its cool that you can do crazy stuff I think many people are only interesting in basic scenarios and prefer short and clean solutions.
<TextBlock TextTrimming="LeadingCharacterEllipsis" />
can you try if this also works?
Looks like we did not add these new trimming modes to the parse method: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Media/TextTrimming.cs#L49
@Gillibald should I create a tracking issue for this? Would there be an option to make parameters work like LeadingCharacterEllipsis('...',3)
which already works for scale(1.5)
?
Is your feature request related to a problem? Please describe.
Sometimes its more useful to trim a text at the beginning instead of end.
Describe the solution you'd like
Be able to trim at the beginning. Either by extending the existing
TextTrimming
enum or by adding a new propertyDescribe alternatives you've considered
Using a custom converter
Additional context