I need to know that text in TextBlock has been overflowed that not all text has been displayed by TextBlock. How I can know that?
Thank you.
I need to know that text in TextBlock has been overflowed that not all text has been displayed by TextBlock. How I can know that?
Thank you.
What’s your scenario, exactly?
This is undocumented, but TextBlock.metrics
contains useful information about how the text has been laid out, after the TextBlock is measured. the TextBlock.metrics.arrText
contains an array of each line of text in the TextBlock, which you can inspect to see just what is drawn.
This may not give you enough information if your textblock is getting clipped, instead of wrapped.
`
Scenario is that I need to show full text in tooltip when text is overflowed. When it is fully visible on node then I don’t need tooltip. Using string length can’t be precise so I need to know does text overflow has been used on node. It could be helpful if we could have TextBlock.isTextOverflow or something similar, but this metrics is fine for me.
Thank you
You could do something like this: https://codepen.io/simonsarris/pen/JOovqV?editors=1010
There are two textblocks, “Alpha” and “D”.
The tooltip checks the textblock.metrics.arrText[0]
(the first line of drawn text), and sees if it matches the textblock.text
. If they do not match, we know that the first line does not contain all the text, so we know that some is missing. So the tooltip is displayed on “Alpha” but not on “D”, since “D” contains all the text.
Doing it this way is contingent on the Textblock actually needing to wrap. You could have designed your template so that the textblock differently.
Yes that works excellent. Thank you. Only for my case it is better to check last array item to ends with ‘…’ ! We are using TextBlock.OverflowEllipsis.