From b92134c6820b5d739fa9ca16a7bb9d8e696635c8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 14 Feb 2023 11:55:14 +0100 Subject: [PATCH] Added failing test for #10246. --- .../ItemsControlTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs index 28e88d1e71..f074972cef 100644 --- a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs @@ -147,6 +147,25 @@ namespace Avalonia.Controls.UnitTests Assert.Equal(new[] { child }, target.GetLogicalChildren()); } + [Fact] + public void Control_Item_Should_Be_Logical_Child_After_Layout() + { + var target = new ItemsControl + { + Template = GetTemplate(), + }; + var root = new TestRoot(target); + var child = new Control(); + + target.Template = GetTemplate(); + target.Items = new[] { child }; + root.LayoutManager.ExecuteInitialLayoutPass(); + + Assert.Equal(target, child.Parent); + Assert.Equal(target, child.GetLogicalParent()); + Assert.Equal(new[] { child }, target.GetLogicalChildren()); + } + [Fact] public void Added_Container_Should_Have_LogicalParent_Set_To_ItemsControl() {