Browse Source

Fixed ContentPresenter add/remove from logicalchildren otside teamplate

pull/568/head
donandren 10 years ago
parent
commit
b89d75f43a
  1. 13
      src/Avalonia.Controls/Presenters/ContentPresenter.cs

13
src/Avalonia.Controls/Presenters/ContentPresenter.cs

@ -279,12 +279,21 @@ namespace Avalonia.Controls.Presenters
if (oldChild?.LogicalParent == this)
{
((ISetLogicalParent)oldChild).SetParent(null);
LogicalChildren.Remove(oldChild);
}
if (newChild.Parent == null)
{
((ISetLogicalParent)newChild).SetParent((ILogical)this.TemplatedParent ?? this);
var templatedLogicalParent = TemplatedParent as ILogical;
if (templatedLogicalParent != null)
{
((ISetLogicalParent)newChild).SetParent(templatedLogicalParent);
}
else
{
LogicalChildren.Add(newChild);
}
}
VisualChildren.Add(newChild);

Loading…
Cancel
Save