在我的应用程序中,我想用 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))
};
}
运行此代码片段会显示以下内容:
关于c# - 如何创建 shelltoast?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13980864/