diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index d8e7f3a387..317b6d3f2e 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -652,8 +652,8 @@ namespace Avalonia.Controls PlatformImpl?.Show(); Renderer?.Start(); + SetWindowStartupLocation(Owner?.PlatformImpl); } - SetWindowStartupLocation(Owner?.PlatformImpl); OnOpened(EventArgs.Empty); } diff --git a/src/Avalonia.Controls/WindowBase.cs b/src/Avalonia.Controls/WindowBase.cs index eb6e7319f5..1efd6c8c1d 100644 --- a/src/Avalonia.Controls/WindowBase.cs +++ b/src/Avalonia.Controls/WindowBase.cs @@ -39,6 +39,7 @@ namespace Avalonia.Controls public static readonly StyledProperty TopmostProperty = AvaloniaProperty.Register(nameof(Topmost)); + private int _autoSizing; private bool _hasExecutedInitialLayoutPass; private bool _isActive; private bool _ignoreVisibilityChange; @@ -97,11 +98,7 @@ namespace Avalonia.Controls /// /// Whether an auto-size operation is in progress. /// - protected bool AutoSizing - { - get; - private set; - } + protected bool AutoSizing => _autoSizing > 0; /// /// Gets or sets the owner of the window. @@ -186,8 +183,8 @@ namespace Avalonia.Controls /// protected IDisposable BeginAutoSizing() { - AutoSizing = true; - return Disposable.Create(() => AutoSizing = false); + ++_autoSizing; + return Disposable.Create(() => --_autoSizing); } ///