Home > Blockchain >  Toast Notification with Scenario of Reminder not staying on screen
Toast Notification with Scenario of Reminder not staying on screen

Time:10-25

I've built a C# Winforms App in which I've included toast notifications. The notifications work fine. However, when I change the ToastScenario to Reminder, the toast does not stay on screen like the Micorsoft documentation says it should (Reminder A reminder notification. This will be displayed pre-expanded and stay on the user's screen till dismissed.). I have no problem setting the duration to short or long, but I want this notification to stay visible until I interact with it. This app is just for me, so there is no danger of bothering the end user with a notification that persists until they click it. Here is the code that creates my notification:

new ToastContentBuilder()
        .AddText(line1)
        .AddText(line2)
        .AddText(line3)
        .AddArgument("link", link)
        .AddInlineImage(new Uri(image))
        .AddAudio(new Uri("C:\\Windows\\Media\\Alarm10.wav"))
        .SetBackgroundActivation()
        .SetToastScenario(ToastScenario.Reminder)
        .Show();

I'm running the app on Windows 11 Pro. Amy thoughts on how to make the notification stay visible instead of just disappearing into the notifications bar?

CodePudding user response:

I think Reminders require a button (an action that dismisses the toast). I added a button to my Toast and now it persists until the button is clicked. Like this:

new ToastContentBuilder()
            .SetToastScenario(ToastScenario.Reminder)
            .AddText(line1)
            .AddText(line2)
            .AddText(line3)
            .AddButton(new ToastButton()
                .SetContent("View")
                .AddArgument("link", link)
                .SetBackgroundActivation())
            .AddInlineImage(new Uri(image))
            .AddAudio(new Uri("C:\\Windows\\Media\\Alarm10.wav"))
            .Show();
  • Related