吐司没有显示

时间:2017-01-22 18:21:28

标签: c# notifications uwp windows-10 toast

我试图展示一个简单的吐司,它展示了我部署应用程序的第一个,但它不再显示。我没有对部署之间的代码进行任何改动。它是基本的空白项目,除了在Mainpage中这是唯一的代码

   public MainPage()
    {
        this.InitializeComponent();
    }

    public static void Notification(string title, string content)
    {
        // Construct the visuals of the toast
        ToastVisual visual = new ToastVisual()
        {
            TitleText = new ToastText()
            {
                Text = title
            },

            BodyTextLine1 = new ToastText()
            {
                Text = content,
            },

        };


        ToastContent toastContent = new ToastContent()
        {
            Visual = visual,
        };

        // And create the toast notification
        Windows.Data.Xml.Dom.XmlDocument doc = toastContent.GetXml();
        var toast = new ToastNotification(toastContent.GetXml());

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


    private void buttonShowToast_Tapped(object sender, TappedRoutedEventArgs e)
    {
        Notification("a", "b");
    }

安装NuGet包: NotificationExtensions.Win10(version:14332.0.2)

这很简单,为什么它不起作用?我错过了某种许可吗?

1 个答案:

答案 0 :(得分:1)

我明白了。出于某种原因,Windows 10禁用了使用Visual Studio部署的所有应用程序的通知。走向"通知&操作"在设备的设置中,权限在"从这些发件人获取通知"。

下切换。

将权限切换为" On"为应用程序解决了这个问题。

相关问题