Windows 10 Toast通知视觉和操作无效

时间:2017-03-22 14:25:05

标签: c# push-notification windows-10 toast visual-studio-2017

我正在编写一个c#控制台应用程序,它在Windows 10计算机上的VS2017中发送Toast通知。当我运行我的代码并且只为我的通知定义了自适应文本内容时,它会正确运行并显示所需的文本。如果我添加操作,它将不再显示我定义的自适应文本(下面的“标题”和“内容”),也没有执行所述操作的选项。如果我尝试添加其他视觉效果,例如徽标或图片,则不会显示,但自适应文字不受影响。

string category = "Notifications";

string title = "New Test Notification!;

string content = "Testing push notifications!";

ToastContent toastContent = new ToastContent()
        {
            Visual  = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = title
                        },

                        new AdaptiveText()
                        {
                            Text = content
                        }

                    },
                    /*AppLogoOverride = new ToastGenericAppLogo()
                    {
                        Source = "https://unsplash.it/64?image=883",
                        HintCrop = ToastGenericAppLogoCrop.Circle
                    }*/
                }
            },

        /*Actions  = new ToastActionsCustom()
        {
            Buttons =
            {
                new ToastButton("check", "check")
                {
                    ImageUri = "check.png"
                },

                new ToastButton("cancel", "cancel")
                {
                    ImageUri = "cancel.png"
                }
             }
        }*/
    };

    string toastXml = toastContent.GetContent();
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(toastXml);
    var toast = new ToastNotification(doc);

    ToastNotificationManager.CreateToastNotifier(category).Show(toast);

使用或不使用第一个注释代码块运行上述代码的结果:enter image description here

使用第二个注释代码块运行代码时的结果:enter image description here

0 个答案:

没有答案