c# - 如何创建 shelltoast?

标签 c# windows-phone-8

在我的应用程序中,我想用 ShellToast 通知用户。

只需运行...

var toast = new ShellToast
{
    Title = "Nom nom nom!",
    Content = "More! More! Keep feeding me!",
};
toast.Show();

...什么也没发生,据我所知,它需要从 ScheduledTaskAgent 运行。但是我如何根据命令运行它,并确保它只运行一次呢?

最佳答案

当应用程序是前台应用程序时,您不能使用 ShellToast。它意味着在应用不是前台应用时从后台服务调用。

如果你想拥有类似于 ShellToast 的用户体验,请使用 Coding4fun toolkit ToastPrompt 控件。这是显示如何使用它的代码片段:

    private void ToastWrapWithImgAndTitleClick(object sender, RoutedEventArgs e)
    {
        var toast = GetToastWithImgAndTitle();
        toast.TextWrapping = TextWrapping.Wrap;

        toast.Show();
    }

    private static ToastPrompt GetToastWithImgAndTitle()
    {
        return new ToastPrompt
        {
            Title = "With Image",
            TextOrientation = System.Windows.Controls.Orientation.Vertical,
            Message = LongText,
            ImageSource = new BitmapImage(new Uri("../../ApplicationIcon.png", UriKind.RelativeOrAbsolute))
        };
    }

运行此代码片段会显示以下内容:

ToastPrompt control with image

关于c# - 如何创建 shelltoast?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13980864/

相关文章:

c# - 不要让反序列化的json(jsonnet)被查看

c# - 如何将文件从本地存储传递到 Windows Phone 8.1 中的库?

c# - 识别 AES 算法。是 AES 128 还是 AES 256?

c# - 空源集合清空目标集合

azure - 将视频从 Windows Phone 8 上传到 Azure 存储

c# - 如何从 html 输入按钮单击调用 Windows Phone 8 代码隐藏方法

c# - WindowsPhone : IsSelected property doesn't change in collection

c# - 使用运行时确定的类型参数调用泛型函数

c# - 如何通过 HtmlDocument.InvokeScript 将对象作为参数传递给 javascript

c# - 从内部类获取 DisplayNameAttribute