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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theUserControl_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.