From 1f05ee41bbccbf17de73e5da68d32054b1b61e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Tue, 20 Sep 2022 04:42:58 +0100 Subject: [PATCH] fallback from CenterOwner to CenterScreen when owner is null --- src/Avalonia.Controls/Window.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 03c66aff2b..db161968b0 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -830,10 +830,11 @@ namespace Avalonia.Controls var startupLocation = WindowStartupLocation; if (startupLocation == WindowStartupLocation.CenterOwner && - Owner is Window ownerWindow && - ownerWindow.WindowState == WindowState.Minimized) + (Owner is null || + (Owner is Window ownerWindow && ownerWindow.WindowState == WindowState.Minimized)) + ) { - // If startup location is CenterOwner, but owner is minimized then fall back + // If startup location is CenterOwner, but owner is null or minimized then fall back // to CenterScreen. This behavior is consistent with WPF. startupLocation = WindowStartupLocation.CenterScreen; }