2016-02-19 155 views
1

這是我第一次實施吐司通知,但我有一個按鈕的問題:按鈕吐司NotificationsExtensions沒有出現

enter image description here

我創建使用NotificationsExtensions的Toast通知:

ToastContent tc = new ToastContent() 
     { 
      Visual = new ToastVisual() 
      { 
       TitleText = new ToastText() { Text = "Quick Save" }, 
       BodyTextLine1 = new ToastText() { Text = "Type below the info that you wanna save and press enter" } 
      }, 
      Actions = new ToastActionsCustom() 
      { 
       Inputs = 
       { 
        new ToastTextBox(nameBox) 
        { 
         PlaceholderContent = "type here" 
        } 
       }, 

       Buttons = 
       { 
        new ToastButton("save", "save") 
        { 
         TextBoxId = nameBox 
        } 
       } 
      }, 
       Duration = ToastDuration.Short 
      }; 

回答

2

您忘記了添加ImageUri您的按鈕

ToastContent tc = new ToastContent() 
{ 
    Visual = new ToastVisual() 
    { 
     TitleText = new ToastText() 
     { 
      Text = "Quick Save" 
     }, 
     BodyTextLine1 = new ToastText() 
     { 
      Text = "Type below the info that you wanna save and press enter" 
     } 
    }, 

    Actions = new ToastActionsCustom() 
    { 
     Inputs = 
     { 
      new ToastTextBox("nameBox") 
      { 
       PlaceholderContent = "type here" 
      } 
     }, 

     Buttons = 
     { 
      new ToastButton("save", "save") 
      { 
       TextBoxId = "nameBox", 
       ImageUri = "Assets/check.png" 
      } 
     } 
    } 
}; 

var text = tc.GetContent(); 
var xml = tc.GetXml(); 
var toast = new ToastNotification(xml); 
ToastNotificationManager.CreateToastNotifier().Show(toast); 

enter image description here

+0

爲什麼ImageUri很重要?如果我想要一個真正的按鈕? –

+0

@HeribertoFilho來自微軟的設計。 –

+0

當您使用快速回復樣式按鈕時,需要圖片。 如果您想在文本框下方使用普通按鈕,請不要在ToastButton上指定TextBoxId屬性,並且它會作爲普通按鈕顯示在文本框下方,以顯示文本。 –