@ -93,6 +93,7 @@ namespace Avalonia.Controls
private bool _ isExtendedIntoWindowDecorations ;
private Thickness _ windowDecorationMargin ;
private Thickness _ offScreenMargin ;
private bool _ canHandleResized = false ;
/// <summary>
/// Defines the <see cref="SizeToContent"/> property.
@ -722,6 +723,8 @@ namespace Avalonia.Controls
// thus we ought to call it again later to center window correctly if needed, when scaling will be already applied
SetWindowStartupLocation ( owner ) ;
_ canHandleResized = true ;
var initialSize = new Size (
double . IsNaN ( Width ) ? Math . Max ( MinWidth , ClientSize . Width ) : Width ,
double . IsNaN ( Height ) ? Math . Max ( MinHeight , ClientSize . Height ) : Height ) ;
@ -800,6 +803,8 @@ namespace Avalonia.Controls
// determined only by calling this method. But here it will calculate not precise location because scaling may not yet be applied (see i.e. X11Window),
// thus we ought to call it again later to center window correctly if needed, when scaling will be already applied
SetWindowStartupLocation ( owner ) ;
_ canHandleResized = true ;
var initialSize = new Size (
double . IsNaN ( Width ) ? ClientSize . Width : Width ,
@ -1036,7 +1041,7 @@ namespace Avalonia.Controls
/// <inheritdoc/>
internal override void HandleResized ( Size clientSize , WindowResizeReason reason )
{
if ( ClientSize ! = clientSize | | double . IsNaN ( Width ) | | double . IsNaN ( Height ) )
if ( _ canHandleResized & & ( ClientSize ! = clientSize | | double . IsNaN ( Width ) | | double . IsNaN ( Height ) ) )
{
var sizeToContent = SizeToContent ;