From 9b68067a15f3beff2edc9e4db06b9545cac6e0a1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 20 Nov 2017 23:14:26 +0100 Subject: [PATCH] Fix ContentPresenter logical parent logic. `ContentPresenter` should only be manually setting its child's logical parent when it is outside of a control template. When it's inside a control template, setting the logical parent will be handled by `ContentControlMixin`. Fixes #1271. --- .../Presenters/ContentPresenter.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index c1adff402a..97760b5632 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -255,18 +255,9 @@ namespace Avalonia.Controls.Presenters LogicalChildren.Remove(oldChild); } - if (newChild.Parent == null) + if (newChild.Parent == null && TemplatedParent == null) { - var templatedLogicalParent = TemplatedParent as ILogical; - - if (templatedLogicalParent != null) - { - ((ISetLogicalParent)newChild).SetParent(templatedLogicalParent); - } - else - { - LogicalChildren.Add(newChild); - } + LogicalChildren.Add(newChild); } VisualChildren.Add(newChild);