Reputation: 11722
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.
ToastNotification
?Upvotes: 4
Views: 1521
Reputation: 1796
If you only want users to be able to access your single app (e.g. for a kiosk in a public place), you can use Assigned Access / Kiosk Mode. Here's some documentation links:
Upvotes: 0
Reputation: 985
There's no supported way to add buttons to the lock screen - only text.
The Spotify "widget" is simply the Now Playing UI, which is only relevant for media apps.
You can make a toast "continuously" display by changing it into a reminder. That'll make the toast stay on screen till the user dismisses it.
ToastContent content = new ToastContent()
{
Scenario = ToastScenario.Reminder,
Visual = new ToastVisual()
However, using toasts for this is likely an abuse of toast notifications. But it might make sense in your scenario.
Upvotes: 3