I can't seem to ever get HasOverflowContent
to fire on a RichTextBlock
, even if I force it to update its layout. Here is what I've tried:
public MainPage()
{
this.InitializeComponent();
RichTextBlock block = new RichTextBlock();
RichTextBlockOverflow overflow = new RichTextBlockOverflow();
block.OverflowContentTarget = overflow;
block.Width = 100;
block.Height = 100;
Paragraph paragraph = new Paragraph();
for (int i = 0; i < 1000; i++)
{
Run run = new Run();
run.Text = "FILLER";
paragraph.Inlines.Add(run);
}
block.Blocks.Add(paragraph);
block.UpdateLayout();
if (block.HasOverflowContent)
{
// This line will never be hit.
}
MainGrid.Children.Add(block);
}
Why isn't HasOverflowContent
signaling it that it does, in fact, have overflow content?
Edit: Okay, I was able to subscribe to this.Loaded
on the MainPage
constructor and this setting does show up correctly in such a case, however, its not good enough for my application so how can I check this outside of the loaded event?