[英]C# .NetCore windows Notification?
所以 ToastContentBuilder 不知何故不起作用。 我假設 Builder 應該創建一個 XML,然后將其放入 ToastNotification。 使用 .NetCore 3.1 不起作用(可能在其他一些框架中它起作用)。 所以解決這個問題的方法是自己創建 XML 文件。 所以這里有一個大家可以用的function。 唯一需要編輯才能在其他代碼中工作的是 at.CreateToast Notifier。 您必須在此處輸入項目的名稱。
public static void showToastNotification(string toastText)
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
for (int i = 0; i < stringElements.Length; i++)
{
stringElements[i].AppendChild(toastXml.CreateTextNode(toastText));
}
ToastNotification toast = new ToastNotification(toastXml);
toast.Activated += Toast_Activated;
toast.Dismissed += Toast_Dismissed;
toast.Failed += Toast_Failed;
ToastNotificationManager.CreateToastNotifier("'Your project name'").Show(toast);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.