CrazyChief
CrazyChief

Reputation: 197

RichTextBlockOverflow.HasOverflowContent always false in Windows 8 Metro app

since you have to support multiple screen resolutions in Windows 8 Metro Apps I want to split up my RichTextBlock to show text that would be cut off in a RichTextBlockOverflow control (or multiple controls, depending how much text I have to show). In order to determine if I have to show an additional RichTextBlockOverflow-Control I check the HasOverflowContent-Property of my RichTextBlocks. But it always returns false.

It's super easy to reproduce:

Then go the code behind file (MainPage.xaml.cs) and replace the constructor with that code:

public MainPage()
{
    this.InitializeComponent();
    if (test.HasOverflowContent)
    {
        // Will never be entered
    }
    if (test1.HasOverflowContent)
    {
        // Will never be entered
    }
}

Set a breakpoint in the on this.InitializeComponent() and see how the HasOverflowContent will never be true.

What am I doing wrong? Or is it a bug in .NET?

Any help would be very appreciated ;)

Andi

Upvotes: 3

Views: 584

Answers (1)

Mark Hall
Mark Hall

Reputation: 54532

Try using a different event, by putting your code in the Page_Loaded event I was able to get HasOverflowContent to work.

Upvotes: 2

Related Questions