diff --git a/src/Controls/src/Core/Window/Window.cs b/src/Controls/src/Core/Window/Window.cs index 392fa4be5507..a53a9e5e4324 100644 --- a/src/Controls/src/Core/Window/Window.cs +++ b/src/Controls/src/Core/Window/Window.cs @@ -206,7 +206,7 @@ void IWindow.FrameChanged(Rect frame) var y = Y; var width = Width; var height = Height; - if (new Rect(x, y, width, height) == frame) + if (frame.X == x && frame.Y == y && frame.Width == width && frame.Height == height) return; _batchFrameUpdate++; diff --git a/src/Graphics/src/Graphics/Rect.cs b/src/Graphics/src/Graphics/Rect.cs index 9fe25894d6c0..916743a8beda 100644 --- a/src/Graphics/src/Graphics/Rect.cs +++ b/src/Graphics/src/Graphics/Rect.cs @@ -9,13 +9,34 @@ namespace Microsoft.Maui.Graphics [TypeConverter(typeof(Converters.RectTypeConverter))] public partial struct Rect { + double _height; + double _width; + public double X { get; set; } public double Y { get; set; } - public double Width { get; set; } + public double Width + { + get => _width; + set + { + if (double.IsNaN(value)) + throw new ArgumentOutOfRangeException(nameof(value), value, "Cannot be NaN"); + _width = value; + } + } - public double Height { get; set; } + public double Height + { + get => _height; + set + { + if (double.IsNaN(value)) + throw new ArgumentOutOfRangeException(nameof(value), value, "Cannot be NaN"); + _height = value; + } + } public static Rect Zero = new Rect();