Browse Source

clean up when detaching caption buttons and templates change.

pull/4336/head
Dan Walmsley 6 years ago
parent
commit
fb4601f65b
  1. 6
      src/Avalonia.Controls/Chrome/CaptionButtons.cs
  2. 5
      src/Avalonia.Controls/Chrome/TitleBar.cs

6
src/Avalonia.Controls/Chrome/CaptionButtons.cs

@ -38,12 +38,10 @@ namespace Avalonia.Controls.Chrome
{
if (_disposables != null)
{
var layer = ChromeOverlayLayer.GetOverlayLayer(_hostWindow);
layer?.Children.Remove(this);
_disposables.Dispose();
_disposables = null;
_hostWindow = null;
}
}

5
src/Avalonia.Controls/Chrome/TitleBar.cs

@ -42,6 +42,8 @@ namespace Avalonia.Controls.Chrome
{
base.OnApplyTemplate(e);
_captionButtons?.Detach();
_captionButtons = e.NameScope.Get<CaptionButtons>("PART_CaptionButtons");
if (VisualRoot is Window window)
@ -87,6 +89,9 @@ namespace Avalonia.Controls.Chrome
base.OnDetachedFromVisualTree(e);
_disposables?.Dispose();
_captionButtons?.Detach();
_captionButtons = null;
}
}
}

Loading…
Cancel
Save