1

I've a Toast notification that execute from outside the project (In a background one). Here you have:

private void SendMessage(string title, string text)
{
    ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
    XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
    XmlNodeList textElements = toastXml.GetElementsByTagName("text");
    textElements[0].AppendChild(toastXml.CreateTextNode(title));
    textElements[1].AppendChild(toastXml.CreateTextNode(text));
    ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml));
}

My problem is when I try to execute code when the user click the toast, I want to execute part of the code form the Main project. Is there a way to do this?

Thanks

1

1 Answer 1

0

In this article you can find section Handling activation from a toast notification
Shortly:
after toast clicked OnActivated event invoked and you can check arguments.
Using new toast template:

protected override void OnActivated(IActivatedEventArgs e)
{
  if (e is ToastNotificationActivatedEventArgs)
  {

  }
}

and using old template (like I think you have):

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
   string launchString = args.Arguments
   // ....
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.