Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Verify canvas control is unloaded before removing it #229

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Nov 9, 2021

Because the order of the Loaded/Unloaded events is not guaranteed (see microsoft/microsoft-ui-xaml#1900), removing a W2DGraphicsView from its parent and immediately re-adding it can result in the UserControl_Unloaded handler running after the UserControl_Loaded handler. This causes the W2DGraphicsView to be removed from the visual tree, and its contents to disappear (dotnet/maui#3214).

This change adds a check for the CanvasControl's IsLoaded property to verify that the handler is running at a time when the control has actually been unloaded, rather than running out of order. This check can be removed once/if microsoft/microsoft-ui-xaml#1900 is fixed.

@mattleibow mattleibow merged commit bbfe1de into dotnet:main Nov 9, 2021
@hartez hartez deleted the rapid-remove-add branch November 13, 2021 00:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants