From 4e5cee4378ffe093e37e794833f463461ede5270 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 4 Aug 2015 00:38:59 +0200 Subject: [PATCH] Don't add Panel Logical children twice! --- Perspex.Controls/Panel.cs | 1 - Tests/Perspex.Controls.UnitTests/PanelTests.cs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Perspex.Controls/Panel.cs b/Perspex.Controls/Panel.cs index 2a35bb7267..170c8fa3e6 100644 --- a/Perspex.Controls/Panel.cs +++ b/Perspex.Controls/Panel.cs @@ -57,7 +57,6 @@ namespace Perspex.Controls this.ClearVisualChildren(); this.children.Clear(); this.children.AddRange(value); - this.LogicalChildren.AddRange(value); } } diff --git a/Tests/Perspex.Controls.UnitTests/PanelTests.cs b/Tests/Perspex.Controls.UnitTests/PanelTests.cs index d2c7c4d880..9d3dce7a7e 100644 --- a/Tests/Perspex.Controls.UnitTests/PanelTests.cs +++ b/Tests/Perspex.Controls.UnitTests/PanelTests.cs @@ -84,6 +84,18 @@ namespace Perspex.Controls.UnitTests Assert.Null(child2.GetLogicalParent()); } + [Fact] + public void Setting_Children_Should_Make_Controls_Appear_In_Panel_Children() + { + var panel = new Panel(); + var child = new Control(); + + panel.Children = new Controls { child }; + + Assert.Equal(new[] { child }, panel.Children); + Assert.Equal(new[] { child }, panel.GetLogicalChildren()); + } + [Fact] public void Child_Control_Should_Appear_In_Panel_Children() {