Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows Media Element in MultiWindow Mode on exit Crash #2259

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a6572c0
Track window count and manage snackbar notifications
ne0rrmatrix Oct 5, 2024
be346ab
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Oct 15, 2024
449171b
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Oct 15, 2024
8781fba
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Oct 16, 2024
6b7b89d
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Oct 20, 2024
d34a434
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Oct 31, 2024
b930239
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Nov 5, 2024
7acf09d
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Nov 7, 2024
8badf90
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Nov 11, 2024
f359899
Remove `NumberOfWindows `
brminnick Nov 11, 2024
ea42125
Add null check
brminnick Nov 11, 2024
dec34fc
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Nov 11, 2024
bb78f78
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Dec 2, 2024
e01a483
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Dec 9, 2024
070d5df
Fix Merge Conflict
ne0rrmatrix Dec 18, 2024
d595f02
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Dec 19, 2024
406ece1
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Dec 20, 2024
b7d0175
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Dec 28, 2024
f61e837
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Jan 3, 2025
e2cfffd
Merge branch 'main' into MultiWindowSnackbarFix
ne0rrmatrix Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/CommunityToolkit.Maui/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void SetShouldEnableSnackbarOnWindows(bool value)
{
throw new InvalidOperationException($"{nameof(SetShouldEnableSnackbarOnWindows)} must be called using the {nameof(AppBuilderExtensions.UseMauiCommunityToolkit)} extension method. See the Platform Specific Initialization section of the {nameof(Alerts.Snackbar)} documentaion for more inforamtion: https://learn.microsoft.com/dotnet/communitytoolkit/maui/alerts/snackbar)")
{
HelpLink = "https://learn.microsoft.com/dotnet/communitytoolkit/maui/alerts/snackbar"
};
HelpLink = "https://learn.microsoft.com/dotnet/communitytoolkit/maui/alerts/snackbar"
};
}
else if (value is true && builder is not null)
{
Expand All @@ -68,13 +68,28 @@ public void SetShouldEnableSnackbarOnWindows(bool value)
events.AddWindows(windows => windows
.OnLaunched((_, _) =>
{
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.NotificationInvoked += OnSnackbarNotificationInvoked;
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.Register();
if (Application.Current is null)
{
throw new InvalidOperationException($"{nameof(Application)}.{nameof(Application.Current)} cannot be null when Windows are launched");
}

else if (Application.Current.Windows.Count is 1)
{
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.NotificationInvoked += OnSnackbarNotificationInvoked;
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.Register();
}
})
.OnClosed((_, _) =>
{
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.NotificationInvoked -= OnSnackbarNotificationInvoked;
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.Unregister();
if (Application.Current is null)
{
throw new InvalidOperationException($"{nameof(Application)}.{nameof(Application.Current)} cannot be null when Windows are closed");
}
else if (Application.Current.Windows.Count is 1)
{
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.NotificationInvoked -= OnSnackbarNotificationInvoked;
Microsoft.Windows.AppNotifications.AppNotificationManager.Default.Unregister();
}
}));
});

Expand Down
Loading