2
votes

I have a TextBlock in my XAML page. The text that goes into that TextBlock is dynamic and can be any number of characters. Initially I keep TextWrapping = Wrap. But when I click on the TextBlock, I switch TextWrapping to NoWrap by using the Tapped event on the TextBlock and clicking it again switches it back to Wrap. So essentially Tapped event on the TextBlock toggles between Wrap and NoWrap. This allows me to expand the TextBlock to read the whole text in it.

This is all good. Now what I am trying to do is to show some indication inside the TextBlock that tells whether some text inside the TextBlock is getting wrapped so that the user can click on the TextBlock and expand it to read the whole thing. The indication I wanted to show was something like 3 dots at the end of the TextBlock if the text is getting wrapped. For example if the text inside the TextBox is

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit"

but because TextWrapping = Wrap, it is getting wrapped after the word 'est' , then I want the content of the TextBlock to be something like this:

Neque porro quisquam est...

(notice the 3 dots after the word est)

How do I achieve this? ( if possible ).

1

1 Answers

4
votes

I believe you are simply looking for the TextTrimming property of the TextBlock.

Pick either CharacterEllipsis or WordEllipsis to suit you need.