diff --git a/src/Toolkit/Toolkit.Maui/BasemapGallery/BasemapGallery.cs b/src/Toolkit/Toolkit.Maui/BasemapGallery/BasemapGallery.cs index 7597dea50..3e28f8767 100644 --- a/src/Toolkit/Toolkit.Maui/BasemapGallery/BasemapGallery.cs +++ b/src/Toolkit/Toolkit.Maui/BasemapGallery/BasemapGallery.cs @@ -49,6 +49,9 @@ public BasemapGallery() private async void BasemapGallery_Loaded(object? sender, EventArgs e) { + // Unsubscribe from the Loaded event to ensure this only runs once. + Loaded -= BasemapGallery_Loaded; + if (AvailableBasemaps is null) { _loadCancellationTokenSource = new CancellationTokenSource(); diff --git a/src/Toolkit/Toolkit.UI.Controls/BasemapGallery/BasemapGallery.Windows.cs b/src/Toolkit/Toolkit.UI.Controls/BasemapGallery/BasemapGallery.Windows.cs index dd6cc8258..93edb92d2 100644 --- a/src/Toolkit/Toolkit.UI.Controls/BasemapGallery/BasemapGallery.Windows.cs +++ b/src/Toolkit/Toolkit.UI.Controls/BasemapGallery/BasemapGallery.Windows.cs @@ -53,6 +53,9 @@ public BasemapGallery() private async void BasemapGallery_Loaded(object? sender, RoutedEventArgs e) { + // Unsubscribe from the Loaded event to ensure this only runs once. + Loaded -= BasemapGallery_Loaded; + if (AvailableBasemaps is null) { _loadCancellationTokenSource = new CancellationTokenSource();