2016-07-18 56 views
0

我的吐司通知工作正常,我可以添加一些按鈕,並檢查哪個按鈕被按下。現在我需要檢查通知中的文本框的輸入,但我不知道如何。我在Google上搜索了類似的內容,但沒有發現任何內容。如何檢查文本框輸入吐司通知C#

我的吐司通知看起來不錯,但我只能得到信息,哪個按鈕被按下。
Here is how it looks like.

protected ToastButton tsen = new ToastButton("reply", "reply") { ImageUri = "Assets/reply.png", TextBoxId = "txtboxrep"}; 
protected ToastTextBox txtboxrep = new ToastTextBox("txtboxrep"); 

ToastContent content = new ToastContent() 
     { 
      Launch = "TextBox", 
      Visual = new ToastVisual() 
      { 
       TitleText = new ToastText() { Text = "Please fill in the gap." }, 
       BodyTextLine1 = new ToastText() { Text = "I need the following information:" }, 
       BodyTextLine2 = new ToastText() { Text = txtboxmes } 
      }, 
      Actions = new ToastActionsCustom() 
      { 
       Inputs = { txtboxrep }, 
       Buttons = { tsen }, 
      }, 
     }; 

private void TText_Activated(ToastNotification sender, object args) 
    { 
     //I try to get the text 
     var targs = args as ToastActivatedEventArgs; 
     ttextreply = targs.Arguments; 
     //I only get "reply", this is the buttons name 
    } 
+0

爲人們尋找在與用戶的文本輸入非UWP /桌面應用程序使用的通知祝酒輸入一個完整的例子來看看https://github.com/WindowsNotifications /桌面敬酒。 –

回答

0

ToastNotificationActionTriggerDetail.UserInput

訪問它看到一個例子你可以從激活事件的文本框的值在App.xaml.cs像下面,如果你想:

protected async override void OnActivated(IActivatedEventArgs e) 
{ 
    base.OnActivated(e); 
    try 
    { 
     if (e.Kind == ActivationKind.ToastNotification) 
     { 
      ToastNotificationActivatedEventArgs toastArgs = (ToastNotificationActivatedEventArgs)e; 
      string value = (string)toastArgs.UserInput["txtboxrep"]); 
     } 
    } 
    catch { } 
} 

其中UserInput [「」]是您的文本框的名稱/ ID,並且應該爲其設置值「value」。

我有以下網址https://comentsys.wordpress.com/2016/05/31/windows-10-universal-windows-platform-toast-input/