2015-02-06 40 views
0

如何實現Android Toast的行爲,即在幾秒鐘後自動解除消息而不需要用戶交互的浮動消息?如何在windows phone中顯示浮動消息(Android Toasts)

enter image description here

感謝

+0

您是否在尋找[toast notification](https://msdn.microsoft.com/en-us/library/windows/apps/hh779727.aspx)? – Romasz 2015-02-06 12:23:09

+0

是的,你可以提供一個snipplet來顯示簡單的信息嗎? – Addev 2015-02-06 12:35:49

回答

2

Windows Phone中有toasts available。它們可以按需顯示或預定。它們顯示在屏幕的頂部並在一段時間後消失。樣本顯示,乾杯需求可以是這樣的:

ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; 
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); 
XmlNodeList textElements = toastXml.GetElementsByTagName("text"); 
textElements[0].AppendChild(toastXml.CreateTextNode("MyApp")); 
textElements[1].AppendChild(toastXml.CreateTextNode("Message")); 
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml)); 

你會發現更多的信息at MSDN

請注意,上面的代碼適用於WP8.1 RunTime和Universal應用程序。如果您正在尋找Silverlight示例,請看一下st ShellToasttutorial at MSDN