diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs
index 1f5d12c536..ee9671edda 100644
--- a/src/Avalonia.Controls/Window.cs
+++ b/src/Avalonia.Controls/Window.cs
@@ -481,6 +481,11 @@ namespace Avalonia.Controls
}
}
+ ///
+ /// Gets whether this window was opened as a dialog
+ ///
+ public bool IsDialog => _showingAsDialog;
+
///
/// Starts moving a window with left button being held. Should be called from left mouse button press event handler
///
@@ -761,12 +766,12 @@ namespace Avalonia.Controls
return null;
}
+ _showingAsDialog = modal;
RaiseEvent(new RoutedEventArgs(WindowOpenedEvent));
EnsureInitialized();
ApplyStyling();
_shown = true;
- _showingAsDialog = modal;
IsVisible = true;
// If window position was not set before then platform may provide incorrect scaling at this time,
@@ -984,7 +989,7 @@ namespace Avalonia.Controls
{
return;
}
-
+
var location = GetEffectiveWindowStartupLocation(owner);
switch (location)
@@ -1017,7 +1022,7 @@ namespace Avalonia.Controls
return startupLocation;
}
-
+
private void SetWindowStartupLocation(Window? owner = null)
{
if (_wasShownBefore)
@@ -1052,7 +1057,7 @@ namespace Avalonia.Controls
screen ??= Screens.ScreenFromPoint(Position);
screen ??= Screens.Primary;
-
+
if (screen is not null)
{
var childRect = screen.WorkingArea.CenterRect(rect);
@@ -1072,7 +1077,7 @@ namespace Avalonia.Controls
var childRect = ownerRect.CenterRect(rect);
var screen = Screens.ScreenFromWindow(owner);
-
+
childRect = ApplyScreenConstraint(screen, childRect);
Position = childRect.Position;
@@ -1080,7 +1085,7 @@ namespace Avalonia.Controls
if (!_positionWasSet && DesktopScaling != PlatformImpl?.DesktopScaling) // Platform returns incorrect scaling, forcing setting position may fix it
PlatformImpl?.Move(Position);
-
+
PixelRect ApplyScreenConstraint(Screen? screen, PixelRect childRect)
{
if (screen?.WorkingArea is { } constraint)