Which exposes the resize reason and new client size. Required renaming `PlatformResizeReason` to `WindowResizeReason`. Made `TopLevel.HandleResized` method internal.
Applying styling in the constructor isn't a good idea as demonstrated by #8549..
Instead apply styling when showing a window, or if it's needed call `ApplyStyling` manually, e.g. in unit tests.
Fixes#8549
* Add Loaded/Unloaded events
* Don't allow OnLoaded() twice unless OnUnloaded() is called
* Call OnLoadedCore within Render()
* Call OnLoadedCore() from OnAttachedToVisualTreeCore by scheduling it on the dispatcher
* Improve comments
* Queue loaded events
* Make the loaded queue static
* Make more members static per review
* Make sure control wasn't already scheduling for Loaded event
* Add locks around HashSet usage for when enumerating
* Remove from loaded queue in OnUnloadedCore() as failsafe
* Make Window raise its own Loaded/Unloaded events
* Attempt to fix leak tests to work with Loaded events
* Make WindowBase raise its own Loaded/Unloaded events
* Move hotkey leak tests to the LeakTest project
* Address some code review comments
* Attempt at actually queueing Loaded events again
* Fix typo
* Minor improvements
* Update controls benchmark
Co-authored-by: Max Katz <maxkatz6@outlook.com>
Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com>
- Run resize logic if `Width`/`Height` are still NaN (i.e. not set up)
- Always call base class `WindowBase.HandleResize`
- In `WindowBase.HandleResize` don't run a layout pass if client size unchanged
Fixes `Width_Height_Should_Not_Be_NaN_After_Show_With_SizeToContent_Manual`.
The validating layer introduced in #7369 has done its job and caught a few bugs, but was causing difficulties in certain places so removing it now.
Fixes#7573
- Adds a "resize reason" to platform `Resized` events
- Which is used by the auto-sizing code to determine whether to reset `SizeToContent`
- Also other improvements to the reset logic for `SizeToContent`:
- Don't reset it if the size hasn't changed
- Don't reset it if `CanResize == false`
- Only reset the dimensions whose size has changed
- Obsolete the `BeginAutoSizing`/`AutoSizing` feature in `WindowBase`
- Allow nested calls to `BeginAutoSizing` - previously it was called twice when showing a window on a secondary monitor and when the second `using` block exited it cleared the autosizing state despite the outer block not completing
- Call `SetWindowStartupLocation` within the auto-sizing block. Moving to a secondary monitor causes a resize message.
Had to remove syncing client size to `Width`/`Height` in `PopupRoot` bceause without the `SizeToContent` property it was impossible to tell whether its `Width`/`Height` came from a requested bound or from the actual window size.
Top-level controls cannot have a `Bounds` offset, and their `(Min)/(Max)/Width` and `(Min)/(Max)/Height` reflects the client size of the actual window, so don't need to be applied at the layout level.
Fixes#3784
This is a relic from when we were targeting a PCL profile that didn't have `System.ComponentModel.ISupportInitialize`. Now that we have that, use it instead.