From cf16418d21815fddd6d8f8a3822c524179b1dae3 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Mon, 10 Oct 2022 18:34:40 +0200 Subject: [PATCH] Adjust visual logical tree reset --- src/Avalonia.Controls/RichTextBlock.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/RichTextBlock.cs b/src/Avalonia.Controls/RichTextBlock.cs index a7eee504ec..d0b713ba56 100644 --- a/src/Avalonia.Controls/RichTextBlock.cs +++ b/src/Avalonia.Controls/RichTextBlock.cs @@ -538,9 +538,14 @@ namespace Avalonia.Controls protected override Size MeasureOverride(Size availableSize) { - LogicalChildren.Clear(); + if(_textRuns != null) + { + LogicalChildren.Clear(); + + VisualChildren.Clear(); - VisualChildren.Clear(); + _textRuns = null; + } if (Inlines != null && Inlines.Count > 0) { @@ -558,7 +563,7 @@ namespace Avalonia.Controls if (textRun is EmbeddedControlRun controlRun && controlRun.Control is Control control) { - ((ISetLogicalParent)control).SetParent(this); + LogicalChildren.Add(control); VisualChildren.Add(control); @@ -568,10 +573,6 @@ namespace Avalonia.Controls _textRuns = textRuns; } - else - { - _textRuns = null; - } return base.MeasureOverride(availableSize); }