Browse Source

Detach PopupRoot from logical tree...

When parent `Popup` is detached. Together with previous comit also fixes
#706.
pull/712/head
Steven Kirk 10 years ago
parent
commit
b61adbfd64
  1. 9
      src/Avalonia.Controls/Primitives/Popup.cs
  2. 18
      tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs

9
src/Avalonia.Controls/Primitives/Popup.cs

@ -268,8 +268,13 @@ namespace Avalonia.Controls.Primitives
{
base.OnDetachedFromLogicalTree(e);
_topLevel = null;
_popupRoot?.Dispose();
_popupRoot = null;
if (_popupRoot != null)
{
((ISetLogicalParent)_popupRoot).SetParent(null);
_popupRoot.Dispose();
_popupRoot = null;
}
}
/// <summary>

18
tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs

@ -166,6 +166,24 @@ namespace Avalonia.Controls.UnitTests.Primitives
}
}
[Fact]
public void PopupRoot_Should_Be_Detached_From_Logical_Tree_When_Popup_Is_Detached()
{
using (CreateServices())
{
var target = new Popup();
var root = new TestRoot { Child = target };
target.Open();
var popupRoot = (ILogical)target.PopupRoot;
Assert.True(popupRoot.IsAttachedToLogicalTree);
root.Child = null;
Assert.False(((ILogical)target).IsAttachedToLogicalTree);
}
}
[Fact]
public void PopupRoot_Should_Have_Template_Applied()
{

Loading…
Cancel
Save