[英]How can I show custom alerts in UWP or WPF application?
我需要显示或发送通知的 UWP 应用程序或 wpf 应用程序,这些通知也将在锁定屏幕和屏幕保护程序上全屏显示(简而言之,覆盖所有条件并显示警报)。
我在 UWP 中创建了一个示例应用程序,它使用ToastNotification
提供的ToastNotification
,但我们无法自定义它的大小。
public static void ShowAlertNotification()
{
var toastContent = new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "High Alert Message"
},
new AdaptiveText()
{
Text = "Alert from Notifications App"
},
new AdaptiveImage()
{
Source = "Assets/caution.png"
}
}
}
},
Actions = new ToastActionsCustom()
{
Buttons =
{
new ToastButton("Ignore", "action=ignore&callId=938163")
{
ActivationType = ToastActivationType.Protocol,
ImageUri = "Assets/stop.png"
},
new ToastButton("Acknowledged", "action=answer&callId=938163")
{
ActivationType = ToastActivationType.Foreground,
ImageUri = "Assets/correct.png"
}
}
},
Launch = "action=answer&callId=938163",
Scenario = ToastScenario.IncomingCall,
DisplayTimestamp = DateTime.Now,
};
// Create the toast notification
var toastNotif = new ToastNotification(toastContent.GetXml());
// And send the notification
ToastNotificationManager.CreateToastNotifier().Show(toastNotif);
}
默认ToastNotification
具有预定义的类型,如日历、呼叫等。但我需要全屏显示。
我也尝试过在全屏模式下创建 win 表单,而不是使用 service 调用它,但我认为这不是可取的。
我需要这种类型的学校应用程序,它可以向家长发送紧急警报。
那么对此有什么想法或建议吗?
先谢谢了。
使用Azure 通知中心,您可以向移动 UWP 应用发送 Toast 通知,即使应用未运行,您也可以获得该信息。
在 UWP 中,toast 通知的视觉外观取决于运行应用程序的实际设备。 你可以,但是,使用本语法描述扩展它在这篇文章中,但是,作为Faywang - MSFT在评论中提到,
你不能把它设置为全屏(因为我们不能指定 toast 的宽度和高度)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.