What I have done
I got the requirement that the user needs to be able to start my application through the windows lock screen. After searching the www it turned out to hook up hotkeys from the lock screen is very difficult (if not impossible).
Then I found this post which uses
Microsoft.Toolkit.Uwp.Notifications.TileContent
to send notifications to the lock screen.
I found no way to add some buttons or similar controls to the TileContent
so I tried the
Microsoft.Toolkit.Uwp.Notifications.ToastContent
I successfully added a button and I was possible to show the ToastNotification
like this
ToastContent content = new ToastContent()
{
Duration = ToastDuration.Long,
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);
With this approach I have the problem the ToastNotification
disapears after a specific amount of time. The ToastContent.Duration
property cannot be set to "continuously" or something like that.
Question
- Is there a way to continuously display the
ToastNotification
? - If not, is there another way to trigger my application through the lock screen via buttons (or other controls) like the Spotify widget does it. (see screenshot of the linked post)