Browse Source

Merge pull request #11095 from AvaloniaUI/fixes/window-resized-sizechanged-order

Raise WindowBase.Resized before SizeChanged.
gh-readonly-queue/master/pr-11141-95256f92b8a5823ccdcfba3f218ea5c2732eb79c
Max Katz 3 years ago
committed by GitHub
parent
commit
f949fdffee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      src/Avalonia.Controls/WindowBase.cs

23
src/Avalonia.Controls/WindowBase.cs

@ -83,6 +83,19 @@ namespace Avalonia.Controls
/// <summary>
/// Occurs when the window is resized.
/// </summary>
/// <remarks>
/// Although this event is similar to the <see cref="Control.SizeChanged"/> event, they are
/// conceptually different:
///
/// - <see cref="Resized"/> is a window-level event, fired when a resize notification arrives
/// from the platform windowing subsystem. The event args contain details of the source of
/// the resize event in the <see cref="WindowResizedEventArgs.Reason"/> property. This
/// event is raised before layout has been run on the window's content.
/// - <see cref="Control.SizeChanged"/> is a layout-level event, fired when a layout pass
/// completes on a control. <see cref="Control.SizeChanged"/> is present on all controls
/// and is fired when the control's size changes for any reason, including a
/// <see cref="Resized"/> event in the case of a Window.
/// </remarks>
public event EventHandler<WindowResizedEventArgs>? Resized;
public new IWindowBaseImpl? PlatformImpl => (IWindowBaseImpl?) base.PlatformImpl;
@ -237,14 +250,16 @@ namespace Avalonia.Controls
{
FrameSize = PlatformImpl?.FrameSize;
if (ClientSize != clientSize)
var clientSizeChanged = ClientSize != clientSize;
ClientSize = clientSize;
OnResized(new WindowResizedEventArgs(clientSize, reason));
if (clientSizeChanged)
{
ClientSize = clientSize;
LayoutManager.ExecuteLayoutPass();
Renderer.Resized(clientSize);
}
OnResized(new WindowResizedEventArgs(clientSize, reason));
}
/// <summary>

Loading…
Cancel
Save