From f41ded2b7f4c435bdd6639a31d2dff63914864ad Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 20 Nov 2017 23:14:26 +0100 Subject: [PATCH] Revert "Fix ContentPresenter logical parent logic." This reverts commit 9b68067a15f3beff2edc9e4db06b9545cac6e0a1. --- .../Presenters/ContentPresenter.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index 97760b5632..c1adff402a 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -255,9 +255,18 @@ namespace Avalonia.Controls.Presenters LogicalChildren.Remove(oldChild); } - if (newChild.Parent == null && TemplatedParent == null) + if (newChild.Parent == null) { - LogicalChildren.Add(newChild); + var templatedLogicalParent = TemplatedParent as ILogical; + + if (templatedLogicalParent != null) + { + ((ISetLogicalParent)newChild).SetParent(templatedLogicalParent); + } + else + { + LogicalChildren.Add(newChild); + } } VisualChildren.Add(newChild);