diff --git a/src/Avalonia.Controls/Documents/InlineCollection.cs b/src/Avalonia.Controls/Documents/InlineCollection.cs index 54ee9c99d5..a265f88e21 100644 --- a/src/Avalonia.Controls/Documents/InlineCollection.cs +++ b/src/Avalonia.Controls/Documents/InlineCollection.cs @@ -12,7 +12,7 @@ namespace Avalonia.Controls.Documents [WhitespaceSignificantCollection] public class InlineCollection : AvaloniaList { - private IAvaloniaList? _parent; + private IAvaloniaList? _logicalChildren; private IInlineHost? _inlineHost; /// @@ -26,26 +26,28 @@ namespace Avalonia.Controls.Documents x => { x.InlineHost = InlineHost; - Parent?.Add(x); + LogicalChildren?.Add(x); Invalidate(); }, x => { - Parent?.Remove(x); + LogicalChildren?.Remove(x); x.InlineHost = InlineHost; Invalidate(); }, () => throw new NotSupportedException()); } - internal IAvaloniaList? Parent + internal IAvaloniaList? LogicalChildren { - get => _parent; + get => _logicalChildren; set { - _parent = value; + var oldValue = _logicalChildren; - OnParentChanged(_parent, value); + _logicalChildren = value; + + OnParentChanged(oldValue, value); } } @@ -116,7 +118,7 @@ namespace Avalonia.Controls.Documents private void AddText(string text) { - if (Parent is TextBlock textBlock && !textBlock.HasComplexContent) + if (LogicalChildren is TextBlock textBlock && !textBlock.HasComplexContent) { textBlock._text += text; } @@ -128,7 +130,7 @@ namespace Avalonia.Controls.Documents private void OnAdd() { - if (Parent is TextBlock textBlock) + if (LogicalChildren is TextBlock textBlock) { if (!textBlock.HasComplexContent && !string.IsNullOrEmpty(textBlock._text)) { diff --git a/src/Avalonia.Controls/Documents/Span.cs b/src/Avalonia.Controls/Documents/Span.cs index 041cdc74ce..a7a702ceae 100644 --- a/src/Avalonia.Controls/Documents/Span.cs +++ b/src/Avalonia.Controls/Documents/Span.cs @@ -21,7 +21,7 @@ namespace Avalonia.Controls.Documents { Inlines = new InlineCollection { - Parent = LogicalChildren + LogicalChildren = LogicalChildren }; } @@ -78,14 +78,14 @@ namespace Avalonia.Controls.Documents { if (oldValue is not null) { - oldValue.Parent = null; + oldValue.LogicalChildren = null; oldValue.InlineHost = null; oldValue.Invalidated -= (s, e) => InlineHost?.Invalidate(); } if (newValue is not null) { - newValue.Parent = LogicalChildren; + newValue.LogicalChildren = LogicalChildren; newValue.InlineHost = InlineHost; newValue.Invalidated += (s, e) => InlineHost?.Invalidate(); } diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index 75a275f778..f79d3f8296 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -156,7 +156,7 @@ namespace Avalonia.Controls { Inlines = new InlineCollection { - Parent = LogicalChildren, + LogicalChildren = LogicalChildren, InlineHost = this }; } @@ -772,14 +772,14 @@ namespace Avalonia.Controls { if (oldValue is not null) { - oldValue.Parent = null; + oldValue.LogicalChildren = null; oldValue.InlineHost = null; oldValue.Invalidated -= (s, e) => InvalidateTextLayout(); } if (newValue is not null) { - newValue.Parent = LogicalChildren; + newValue.LogicalChildren = LogicalChildren; newValue.InlineHost = this; newValue.Invalidated += (s, e) => InvalidateTextLayout(); }