Browse Source

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.
Steven Kirk 8 years ago
parent
commit
9b68067a15
1 changed files with 2 additions and 11 deletions
  1. 2 11
      src/Avalonia.Controls/Presenters/ContentPresenter.cs

+ 2 - 11
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);