This state is not actually invalid: it can happen when running an empty batch update of >1 value which causes new, empty batch update to run in a `PropertyChanged` handler triggered from the first batch update.
When a control was move from one parent container to another, and that move caused the new parent container to be laid out in a different position, a code path was taken which resulted in the `VisualNode` being present under both the old and new containers.
Ensure that the node is removed from its old parent in this case.
Fixes#7381Fixes#6103 (probably)
* 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>
The call to `_subscription.Dispose()` causes `BindingEntry.Dispose()` to call `_subscription.Dispose()`, but in this case the `BindingEntry._subscription` instance is the `PropertySetterInstance`!
Except now `PropertySetterInstance._subscription` is null, and so `PropertySetterInstance.Dispose` called `ClearValue`, which is obviously wrong.