I'm using RichTextBlock
in Windows Phone 8.1 RT to show some text. To limit the size of the text that can be displayed at a given time, I'm setting the MaxLines
property. Whenever the text exceeds this value, it's trimmed.
Now, I have a hyperlink at the bottom of the RichTextBlock
that should get visible whenever the text is trimmed. For detecting if the text was trimmed, I'm using the RichTextBlock.HasOverflowContent
. If this property is set to true, I set to visibility of the hyperlink to visible so the user can click on it and see the full untrimmed message.
But there is a problem with this solution. Sometimes the text is trimmed, but the property is still false and the hyperlink stays hidden.
I don't really know how to use the above property to detect content trimming. What's the correct way to use this? I'm doing the processing in the Loaded
event of the RichTextBlock
:
private void RichTextBlock_Loaded(object sender, RoutedEventArgs e)
{
var richtextblock = sender as RichTextBlock;
// Check if the content of the RichTextBlock was trimmed.
if (richtextblock.HasOverflowContent)
{
// Prepare hyperlink and set visibility to visible.
}
}