Seems to cause less flaky tests; `mainWindow.Click()` clicks the main window in the middle, where the secondary window is shown, so don't go out of our way to put the secondary window in front of where we're clicking.
* 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>
Exposed by the previous fix for #8372: re-entrancy in `PropertySetterInstance.Dispose()` is causing detaching a style to call `ClearValue` on the property. Previously this wasn't a problem as `ClearValue` didn't work, but now it is.
(Also added one passing test which tests the same scenario in `PropertySetterBindingInstance` for future coverage)