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.
pull/1284/head
Steven Kirk 8 years ago
parent
commit
9b68067a15
  1. 13
      src/Avalonia.Controls/Presenters/ContentPresenter.cs

13
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);

Loading…
Cancel
Save