diff --git a/src/Avalonia.Base/Input/InputElement.cs b/src/Avalonia.Base/Input/InputElement.cs index 26ebf86857..c7be77e17b 100644 --- a/src/Avalonia.Base/Input/InputElement.cs +++ b/src/Avalonia.Base/Input/InputElement.cs @@ -682,7 +682,7 @@ namespace Avalonia.Input // PERF-SENSITIVE: This is called on entire hierarchy and using foreach or LINQ // will cause extra allocations and overhead. - var children = VisualChildren; + var children = Children.Visual; // ReSharper disable once ForCanBeConvertedToForeach for (int i = 0; i < children.Count; ++i) diff --git a/src/Avalonia.Base/Layout/Layoutable.cs b/src/Avalonia.Base/Layout/Layoutable.cs index 7568ea8e09..abb2763c03 100644 --- a/src/Avalonia.Base/Layout/Layoutable.cs +++ b/src/Avalonia.Base/Layout/Layoutable.cs @@ -613,7 +613,7 @@ namespace Avalonia.Layout double width = 0; double height = 0; - var visualChildren = VisualChildren; + var visualChildren = Children.Visual; var visualCount = visualChildren.Count; for (var i = 0; i < visualCount; i++) @@ -716,7 +716,7 @@ namespace Avalonia.Layout { var arrangeRect = new Rect(finalSize); - var visualChildren = VisualChildren; + var visualChildren = Children.Visual; var visualCount = visualChildren.Count; for (var i = 0; i < visualCount; i++) diff --git a/src/Avalonia.Base/StyledElement.cs b/src/Avalonia.Base/StyledElement.cs index 26eb77ca98..d403e7e9ba 100644 --- a/src/Avalonia.Base/StyledElement.cs +++ b/src/Avalonia.Base/StyledElement.cs @@ -235,6 +235,7 @@ namespace Avalonia /// /// Gets the styled element's logical children. /// + [Obsolete("Use Children.Logical or Children.LogicalMutable property")] protected IList LogicalChildren => Children.LogicalMutable; /// @@ -589,12 +590,12 @@ namespace Avalonia element._dataContextUpdating = true; element.OnDataContextBeginUpdate(); - var logicalChildren = element.LogicalChildren; + var logicalChildren = element.Children.Logical; var logicalChildrenCount = logicalChildren.Count; for (var i = 0; i < logicalChildrenCount; i++) { - if (element.LogicalChildren[i] is StyledElement s && + if (logicalChildren[i] is StyledElement s && s.InheritanceParent == element && !s.IsSet(DataContextProperty)) { @@ -653,7 +654,7 @@ namespace Avalonia AttachedToLogicalTree?.Invoke(this, e); } - var logicalChildren = LogicalChildren; + var logicalChildren = Children.Logical; var logicalChildrenCount = logicalChildren.Count; for (var i = 0; i < logicalChildrenCount; i++) @@ -674,7 +675,7 @@ namespace Avalonia OnDetachedFromLogicalTree(e); DetachedFromLogicalTree?.Invoke(this, e); - var logicalChildren = LogicalChildren; + var logicalChildren = Children.Logical; var logicalChildrenCount = logicalChildren.Count; for (var i = 0; i < logicalChildrenCount; i++) diff --git a/src/Avalonia.Base/Visual.cs b/src/Avalonia.Base/Visual.cs index a63e5daa7a..b6e6e9ac89 100644 --- a/src/Avalonia.Base/Visual.cs +++ b/src/Avalonia.Base/Visual.cs @@ -249,6 +249,7 @@ namespace Avalonia /// /// Gets the control's child visuals. /// + [Obsolete("Use Children.Visual or Children.VisualMutable property")] protected IList VisualChildren => Children.VisualMutable; /// @@ -421,7 +422,7 @@ namespace Avalonia AttachedToVisualTree?.Invoke(this, e); InvalidateVisual(); - var visualChildren = VisualChildren; + var visualChildren = Children.Visual; if (visualChildren != null) { @@ -458,7 +459,7 @@ namespace Avalonia DetachedFromVisualTree?.Invoke(this, e); e.Root?.Renderer?.AddDirty(this); - var visualChildren = VisualChildren; + var visualChildren = Children.Visual; if (visualChildren != null) { diff --git a/src/Avalonia.Controls/ContentControl.cs b/src/Avalonia.Controls/ContentControl.cs index 3ad66e7ac7..acfb0b5f1e 100644 --- a/src/Avalonia.Controls/ContentControl.cs +++ b/src/Avalonia.Controls/ContentControl.cs @@ -92,7 +92,7 @@ namespace Avalonia.Controls } /// - IList IContentPresenterHost.LogicalChildren => LogicalChildren; + IList IContentPresenterHost.LogicalChildren => Children.LogicalMutable; /// bool IContentPresenterHost.RegisterContentPresenter(IContentPresenter presenter) @@ -119,12 +119,12 @@ namespace Avalonia.Controls { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } } diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 00ae4b432c..6ff095a0fb 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -384,7 +384,7 @@ namespace Avalonia.Controls private void PopupClosed(object sender, EventArgs e) { - foreach (var i in LogicalChildren) + foreach (var i in Children.Logical) { if (i is MenuItem menuItem) { diff --git a/src/Avalonia.Controls/Decorator.cs b/src/Avalonia.Controls/Decorator.cs index 15e3a69255..f54c9f69ea 100644 --- a/src/Avalonia.Controls/Decorator.cs +++ b/src/Avalonia.Controls/Decorator.cs @@ -73,15 +73,15 @@ namespace Avalonia.Controls if (oldChild != null) { ((ISetLogicalParent)oldChild).SetParent(null); - LogicalChildren.Clear(); - VisualChildren.Remove(oldChild); + Children.LogicalMutable.Clear(); + Children.VisualMutable.Remove(oldChild); } if (newChild != null) { ((ISetLogicalParent)newChild).SetParent(this); - VisualChildren.Add(newChild); - LogicalChildren.Add(newChild); + Children.VisualMutable.Add(newChild); + Children.LogicalMutable.Add(newChild); } } } diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index 4e60b52f83..564cc93a39 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -2329,6 +2329,8 @@ namespace Avalonia.Controls if (ShowGridLines && (_gridLinesRenderer == null)) { _gridLinesRenderer = new GridLinesRenderer(); + + // TODO: Grid requires a visual child that isn't in Children. this.VisualChildren.Add(_gridLinesRenderer); } diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 6b28630bbe..6581c3cf84 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -266,7 +266,7 @@ namespace Avalonia.Controls // it was added to the Items collection. if (container.ContainerControl != null && container.ContainerControl != container.Item) { - LogicalChildren.Add(container.ContainerControl); + Children.LogicalMutable.Add(container.ContainerControl); } } } @@ -284,7 +284,7 @@ namespace Avalonia.Controls // when it is removed from the Items collection. if (container?.ContainerControl != container?.Item) { - LogicalChildren.Remove(container.ContainerControl); + Children.LogicalMutable.Remove(container.ContainerControl); } } } @@ -416,14 +416,14 @@ namespace Avalonia.Controls { var control = i as IControl; - if (control != null && !LogicalChildren.Contains(control)) + if (control != null && !Children.Logical.Contains(control)) { toAdd.Add(control); } } } - ((IAvaloniaList)LogicalChildren).AddRange(toAdd); + ((IAvaloniaList)Children.LogicalMutable).AddRange(toAdd); } /// @@ -447,7 +447,7 @@ namespace Avalonia.Controls } } - ((IAvaloniaList)LogicalChildren).RemoveAll(toRemove); + ((IAvaloniaList)Children.LogicalMutable).RemoveAll(toRemove); } /// diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 0bead04982..e84a5e3bfa 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -602,13 +602,13 @@ namespace Avalonia.Controls if (oldValue != null) { - LogicalChildren.Remove(oldValue); + Children.LogicalMutable.Remove(oldValue); PseudoClasses.Remove(":icon"); } if (newValue != null) { - LogicalChildren.Add(newValue); + Children.LogicalMutable.Add(newValue); PseudoClasses.Add(":icon"); } } diff --git a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs index 8f5c6faf40..e8fa41c680 100644 --- a/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs +++ b/src/Avalonia.Controls/Notifications/WindowNotificationManager.cs @@ -56,7 +56,7 @@ namespace Avalonia.Controls.Notifications /// The window that will host the control. public WindowNotificationManager(Window host) { - if (VisualChildren.Count != 0) + if (Children.Visual.Count != 0) { Install(host); } @@ -168,6 +168,6 @@ namespace Avalonia.Controls.Notifications PseudoClasses.Set(":bottomright", position == NotificationPosition.BottomRight); } - public bool HitTest(Point point) => VisualChildren.HitTestCustom(point); + public bool HitTest(Point point) => Children.Visual.HitTestCustom(point); } } diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index 1a46d84558..6e29491efb 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -256,7 +256,7 @@ namespace Avalonia.Controls.Presenters var content = Content; var oldChild = Child; var newChild = CreateChild(); - var logicalChildren = Host?.LogicalChildren ?? LogicalChildren; + var logicalChildren = Host?.LogicalChildren ?? Children.LogicalMutable; // Remove the old child if we're not recycling it. if (newChild != oldChild) @@ -264,7 +264,7 @@ namespace Avalonia.Controls.Presenters if (oldChild != null) { - VisualChildren.Remove(oldChild); + Children.VisualMutable.Remove(oldChild); logicalChildren.Remove(oldChild); ((ISetInheritanceParent)oldChild).SetParent(oldChild.Parent); } @@ -295,7 +295,7 @@ namespace Avalonia.Controls.Presenters logicalChildren.Add(newChild); } - VisualChildren.Add(newChild); + Children.VisualMutable.Add(newChild); } _createdChild = true; @@ -450,8 +450,8 @@ namespace Avalonia.Controls.Presenters } else if (Child != null) { - VisualChildren.Remove(Child); - LogicalChildren.Remove(Child); + Children.VisualMutable.Remove(Child); + Children.LogicalMutable.Remove(Child); ((ISetInheritanceParent)Child).SetParent(Child.Parent); Child = null; _recyclingDataTemplate = null; diff --git a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs index aeead7bfd0..0c04d3524d 100644 --- a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs +++ b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs @@ -238,10 +238,10 @@ namespace Avalonia.Controls.Presenters Panel = ItemsPanel.Build(); Panel.SetValue(TemplatedParentProperty, TemplatedParent); - LogicalChildren.Clear(); - VisualChildren.Clear(); - LogicalChildren.Add(Panel); - VisualChildren.Add(Panel); + Children.LogicalMutable.Clear(); + Children.VisualMutable.Clear(); + Children.LogicalMutable.Add(Panel); + Children.VisualMutable.Add(Panel); _createdPanel = true; diff --git a/src/Avalonia.Controls/Primitives/HeaderedContentControl.cs b/src/Avalonia.Controls/Primitives/HeaderedContentControl.cs index e55bdbb0eb..d0d5790561 100644 --- a/src/Avalonia.Controls/Primitives/HeaderedContentControl.cs +++ b/src/Avalonia.Controls/Primitives/HeaderedContentControl.cs @@ -76,12 +76,12 @@ namespace Avalonia.Controls.Primitives { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } } diff --git a/src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs b/src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs index 8665c80e19..6a1a123df6 100644 --- a/src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs @@ -44,7 +44,7 @@ namespace Avalonia.Controls.Primitives } /// - IList IContentPresenterHost.LogicalChildren => LogicalChildren; + IList IContentPresenterHost.LogicalChildren => Children.LogicalMutable; /// bool IContentPresenterHost.RegisterContentPresenter(IContentPresenter presenter) @@ -71,12 +71,12 @@ namespace Avalonia.Controls.Primitives { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } } diff --git a/src/Avalonia.Controls/Primitives/HeaderedSelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/HeaderedSelectingItemsControl.cs index 9ff51848cc..ebb64f7196 100644 --- a/src/Avalonia.Controls/Primitives/HeaderedSelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/HeaderedSelectingItemsControl.cs @@ -44,7 +44,7 @@ namespace Avalonia.Controls.Primitives } /// - IList IContentPresenterHost.LogicalChildren => LogicalChildren; + IList IContentPresenterHost.LogicalChildren => Children.LogicalMutable; /// bool IContentPresenterHost.RegisterContentPresenter(IContentPresenter presenter) @@ -71,12 +71,12 @@ namespace Avalonia.Controls.Primitives { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } } diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index 0f15f647dc..a16a11e08f 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -583,14 +583,14 @@ namespace Avalonia.Controls.Primitives /// The event args. private void ChildChanged(AvaloniaPropertyChangedEventArgs e) { - LogicalChildren.Clear(); + Children.LogicalMutable.Clear(); ((ISetLogicalParent?)e.OldValue)?.SetParent(null); if (e.NewValue != null) { ((ISetLogicalParent)e.NewValue).SetParent(this); - LogicalChildren.Add((ILogical)e.NewValue); + Children.LogicalMutable.Add((ILogical)e.NewValue); } } diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs index 59975b072d..7206388b54 100644 --- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs +++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs @@ -255,7 +255,7 @@ namespace Avalonia.Controls.Primitives // and we don't need to do anything. if (_appliedTemplate != template && (template != null || logical.IsAttachedToLogicalTree)) { - if (VisualChildren.Count > 0) + if (Children.Visual.Count > 0) { foreach (var child in this.GetTemplateChildren()) { @@ -263,7 +263,7 @@ namespace Avalonia.Controls.Primitives ((ISetLogicalParent)child).SetParent(null); } - VisualChildren.Clear(); + Children.VisualMutable.Clear(); } if (template != null) @@ -273,7 +273,7 @@ namespace Avalonia.Controls.Primitives var (child, nameScope) = template.Build(this); ApplyTemplatedParent(child); ((ISetLogicalParent)child).SetParent(this); - VisualChildren.Add(child); + Children.VisualMutable.Add(child); // Existing code kinda expect to see a NameScope even if it's empty if (nameScope == null) @@ -307,11 +307,12 @@ namespace Avalonia.Controls.Primitives protected sealed override void NotifyChildResourcesChanged(ResourcesChangedEventArgs e) { - var count = VisualChildren.Count; + var children = Children.Visual; + var count = children.Count; for (var i = 0; i < count; ++i) { - if (VisualChildren[i] is ILogical logical) + if (children[i] is ILogical logical) { logical.NotifyResourcesChanged(e); } @@ -323,9 +324,11 @@ namespace Avalonia.Controls.Primitives /// protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { - if (VisualChildren.Count > 0) + var children = Children.Visual; + + if (children.Count > 0) { - ((ILogical)VisualChildren[0]).NotifyAttachedToLogicalTree(e); + ((ILogical)children[0]).NotifyAttachedToLogicalTree(e); } base.OnAttachedToLogicalTree(e); @@ -334,9 +337,11 @@ namespace Avalonia.Controls.Primitives /// protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - if (VisualChildren.Count > 0) + var children = Children.Visual; + + if (children.Count > 0) { - ((ILogical)VisualChildren[0]).NotifyDetachedFromLogicalTree(e); + ((ILogical)children[0]).NotifyDetachedFromLogicalTree(e); } base.OnDetachedFromLogicalTree(e); diff --git a/src/Avalonia.Controls/Primitives/Track.cs b/src/Avalonia.Controls/Primitives/Track.cs index 9399f5fb31..86f83c2b4a 100644 --- a/src/Avalonia.Controls/Primitives/Track.cs +++ b/src/Avalonia.Controls/Primitives/Track.cs @@ -410,15 +410,15 @@ namespace Avalonia.Controls.Primitives { oldThumb.DragDelta -= ThumbDragged; - LogicalChildren.Remove(oldThumb); - VisualChildren.Remove(oldThumb); + Children.LogicalMutable.Remove(oldThumb); + Children.VisualMutable.Remove(oldThumb); } if (newThumb != null) { newThumb.DragDelta += ThumbDragged; - LogicalChildren.Add(newThumb); - VisualChildren.Add(newThumb); + Children.LogicalMutable.Add(newThumb); + Children.VisualMutable.Add(newThumb); } } @@ -429,14 +429,14 @@ namespace Avalonia.Controls.Primitives if (oldButton != null) { - LogicalChildren.Remove(oldButton); - VisualChildren.Remove(oldButton); + Children.LogicalMutable.Remove(oldButton); + Children.VisualMutable.Remove(oldButton); } if (newButton != null) { - LogicalChildren.Add(newButton); - VisualChildren.Add(newButton); + Children.LogicalMutable.Add(newButton); + Children.VisualMutable.Add(newButton); } } diff --git a/src/Avalonia.Controls/Primitives/VisualLayerManager.cs b/src/Avalonia.Controls/Primitives/VisualLayerManager.cs index 03a84e26f2..7aaaa0d704 100644 --- a/src/Avalonia.Controls/Primitives/VisualLayerManager.cs +++ b/src/Avalonia.Controls/Primitives/VisualLayerManager.cs @@ -94,7 +94,7 @@ namespace Avalonia.Controls.Primitives _layers.Add(layer); ((ISetLogicalParent)layer).SetParent(this); layer.ZIndex = zindex; - VisualChildren.Add(layer); + Children.VisualMutable.Add(layer); if (((ILogical)this).IsAttachedToLogicalTree) ((ILogical)layer).NotifyAttachedToLogicalTree( new LogicalTreeAttachmentEventArgs(_logicalRoot, layer, this)); diff --git a/src/Avalonia.Controls/TabControl.cs b/src/Avalonia.Controls/TabControl.cs index 788f5362e2..44403bf584 100644 --- a/src/Avalonia.Controls/TabControl.cs +++ b/src/Avalonia.Controls/TabControl.cs @@ -136,7 +136,7 @@ namespace Avalonia.Controls internal IContentPresenter ContentPart { get; private set; } /// - IList IContentPresenterHost.LogicalChildren => LogicalChildren; + IList IContentPresenterHost.LogicalChildren => Children.LogicalMutable; /// bool IContentPresenterHost.RegisterContentPresenter(IContentPresenter presenter) diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 662a355dac..fe6ce65931 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -116,12 +116,12 @@ namespace Avalonia.Controls { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } @@ -129,12 +129,12 @@ namespace Avalonia.Controls { if (e.OldValue is ILogical oldChild) { - LogicalChildren.Remove(oldChild); + Children.LogicalMutable.Remove(oldChild); } if (e.NewValue is ILogical newChild) { - LogicalChildren.Add(newChild); + Children.LogicalMutable.Add(newChild); } } diff --git a/tests/Avalonia.Base.UnitTests/Interactivity/InteractiveTests.cs b/tests/Avalonia.Base.UnitTests/Interactivity/InteractiveTests.cs index 2ef81827aa..1f4a06380c 100644 --- a/tests/Avalonia.Base.UnitTests/Interactivity/InteractiveTests.cs +++ b/tests/Avalonia.Base.UnitTests/Interactivity/InteractiveTests.cs @@ -426,7 +426,7 @@ namespace Avalonia.Base.UnitTests.Interactivity public bool ClassHandlerInvoked { get; private set; } public new string Name { get; set; } - public IEnumerable Children + public new IEnumerable Children { get { @@ -435,8 +435,8 @@ namespace Avalonia.Base.UnitTests.Interactivity set { - VisualChildren.Clear(); - ((IAvaloniaList)VisualChildren).AddRange(value.Cast()); + base.Children.VisualMutable.Clear(); + ((IAvaloniaList)base.Children.VisualMutable).AddRange(value.Cast()); } } diff --git a/tests/Avalonia.Base.UnitTests/TestVisual.cs b/tests/Avalonia.Base.UnitTests/TestVisual.cs index 0dcf57b23a..8a409cc3cc 100644 --- a/tests/Avalonia.Base.UnitTests/TestVisual.cs +++ b/tests/Avalonia.Base.UnitTests/TestVisual.cs @@ -29,34 +29,34 @@ namespace Avalonia.Base.UnitTests { if (Child != null) { - VisualChildren.Remove(Child); + Children.VisualMutable.Remove(Child); } if (value != null) { - VisualChildren.Add(value); + Children.VisualMutable.Add(value); } } } public void AddChild(Visual v) { - VisualChildren.Add(v); + Children.VisualMutable.Add(v); } public void AddChildren(IEnumerable v) { - ((IAvaloniaList)VisualChildren).AddRange(v); + ((IAvaloniaList)Children.VisualMutable).AddRange(v); } public void RemoveChild(Visual v) { - VisualChildren.Remove(v); + Children.VisualMutable.Remove(v); } public void ClearChildren() { - VisualChildren.Clear(); + Children.VisualMutable.Clear(); } } } diff --git a/tests/Avalonia.Controls.UnitTests/TestTemplatedControl.cs b/tests/Avalonia.Controls.UnitTests/TestTemplatedControl.cs index 7636ad9db9..2964552087 100644 --- a/tests/Avalonia.Controls.UnitTests/TestTemplatedControl.cs +++ b/tests/Avalonia.Controls.UnitTests/TestTemplatedControl.cs @@ -9,7 +9,7 @@ namespace Avalonia.Controls.UnitTests public void AddVisualChild(IVisual visual) { - VisualChildren.Add(visual); + Children.VisualMutable.Add(visual); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e)