Search code examples
c#uwptoast

How to set an event for a ToastButton?


Hey I want a toast notification with a Textbox and a Button but I have no idea how I can set an action for the Button. I have a variable and when I click the Button the text in the Textbox should be saved in the variable.

new ToastContentBuilder()
    .AddArgument("conversationId", 9813)
    .AddText("Kein name eingegeben!")
    .AddInputTextBox("nameBox", "Bitte name hier eingeben")
    .AddButton(new ToastButton()
    .SetContent("Bestätigen")
    .AddArgument("action", "apply")
    .SetBackgroundActivation())
    .Show();

This is what I created for now. I hope someone can help me!


Solution

  • The official document mentions ”When the user clicks your notification (or a button on the notification with foreground activation), your app's App.xaml.cs OnActivated will be invoked, and the arguments you added will be returned.” So you could refer to this part know how to handle activation.