diff --git a/src/Perspex.Controls/Mixins/ContentControlMixin.cs b/src/Perspex.Controls/Mixins/ContentControlMixin.cs index 35580081ef..a381c7c773 100644 --- a/src/Perspex.Controls/Mixins/ContentControlMixin.cs +++ b/src/Perspex.Controls/Mixins/ContentControlMixin.cs @@ -74,7 +74,7 @@ namespace Perspex.Controls.Mixins UpdateLogicalChild( sender, logicalChildren, - null, + logicalChildren.FirstOrDefault(), presenter.GetValue(ContentPresenter.ChildProperty)); subscriptions.Value.Add(sender, subscription); diff --git a/tests/Perspex.Controls.UnitTests/ContentControlTests.cs b/tests/Perspex.Controls.UnitTests/ContentControlTests.cs index c3709ed4ff..9eed733da4 100644 --- a/tests/Perspex.Controls.UnitTests/ContentControlTests.cs +++ b/tests/Perspex.Controls.UnitTests/ContentControlTests.cs @@ -98,6 +98,24 @@ namespace Perspex.Controls.UnitTests Assert.Equal(new[] { child }, target.GetLogicalChildren()); } + [Fact] + public void Control_Content_Should_Be_Logical_Child_After_ApplyTemplate() + { + var target = new ContentControl + { + Template = GetTemplate(), + }; + + var child = new Control(); + target.Content = child; + target.ApplyTemplate(); + ((ContentPresenter)target.Presenter).UpdateChild(); + + Assert.Equal(child.Parent, target); + Assert.Equal(child.GetLogicalParent(), target); + Assert.Equal(new[] { child }, target.GetLogicalChildren()); + } + [Fact] public void DataTemplate_Created_Control_Should_Be_Logical_Child_After_ApplyTemplate() {