S
S
Sergey K2018-05-27 04:41:27
C++ / C#
Sergey K, 2018-05-27 04:41:27

What is the correct way to call toast notifications in a Windows Forms project?

Hello,
I can not find any sane information on how to use toast notifications in a Windows Forms project.
Tried through NotificationsExtensions.Win10, but messages are not shown. I understand that the application must first be registered in the system somehow, but I do not understand how.
Here is how I create notification:

private void Button_Click(object sender, RoutedEventArgs e)
{
    ToastContent toastContent = new ToastContent()
    {
        Visual = new ToastVisual()
        {
            BindingGeneric = new ToastBindingGeneric()
            {
                Children =
                {
                    new AdaptiveText()
                    {
                        Text = "Hello world!"
                    }
                }
            }
        }
    };

    var doc = new XmlDocument();
    doc.LoadXml(toastContent.GetContent());

    var toast = new ToastNotification(doc);

    ToastNotificationManager.CreateToastNotifier("Test").Show(toast);
}

The most interesting thing is that I can not find a single example with Windows Forms on the Internet. Maybe someone has already encountered the use of these notifications and can advise something?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey K, 2018-07-09
@AceLightning

The problem lay in the fact that you need to create a program shortcut in the Start Menu with the given parameters: AppUserModel.ID and ToastActivatorCLSID .

S
Semyon Novikov, 2018-05-28
@semennovikov123

Link times
Link 2
Link 3
In general, learn to search for information in English (there will be more information)
Ideally, without any libraries, toast can be used in UWP. That's where you're going.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question