Browse Source

possible solution of bug #539 -
actually ContentPresenter if not used in ContentControl was not detaching it's child from logical tree

donandren 9 years ago
parent
commit
9b230ec1a0
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Avalonia.Controls/Presenters/ContentPresenter.cs

+ 5 - 0
src/Avalonia.Controls/Presenters/ContentPresenter.cs

@@ -277,6 +277,11 @@ namespace Avalonia.Controls.Presenters
 
                 Child = newChild;
 
+                if (oldChild?.LogicalParent == this)
+                {
+                    ((ISetLogicalParent)oldChild).SetParent(null);
+                }
+
                 if (newChild.Parent == null)
                 {
                     ((ISetLogicalParent)newChild).SetParent((ILogical)this.TemplatedParent ?? this);