【发布时间】:2022-01-04 15:40:02
【问题描述】:
我想在单击按钮时在 Windows 10 锁屏上显示自定义文本或控件。我用 UWP 应用程序尝试过。
我的目标是这样的:
我尝试过的代码:
ToastContent content = new ToastContent()
{
//Duration = ToastDuration.Long,
Scenario = ToastScenario.Reminder,
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Attribution = new ToastGenericAttributionText()
{
Text = "Hello World"
}
}
},
Actions = new ToastActionsCustom()
{
Buttons = {
new ToastButton ("mycontent", "myargs")
}
}
};
var notification = new ToastNotification(content.GetXml());
ToastNotificationManager.CreateToastNotifier().Show(notification);
当然我也看到了这个帖子并尝试过,但它没有帮助:Windows Lock Screen display text programmatically C#
也许你可以帮助我实现我的目标 提前谢谢你
【问题讨论】:
-
我能够使用您发布的代码使其在 UWP 项目中工作。在您的 Windows 设置(通知和操作)中,确保您已开启“从应用和其他发件人获取通知”和“在锁定屏幕上显示通知”。
-
@Jesse 谢谢你的回答。一切都打开了,但它仍然不起作用:/
-
@Jesse 如果我点击按钮,会显示通知,但这不是我的目标,如果我点击按钮并锁定我的电脑,我想在锁定屏幕上看到一些东西。我想要 Spotify 或时间和日期之类的东西。
-
这应该很有用,因为您想在锁定屏幕顶部显示自定义窗口 --> stackoverflow.com/a/44406897