我想有一个时间推出举杯显示的过程按钮触发显示与按键举杯后台任务。 “你准备好做xyx了吗?” [是] [否]。点击是,然后转到网页。否,将关闭烤面包片直到下一个时间段。UWP如何在从后台任务
在Windows 10通用应用程序中,我看到了一个示例,其中通用应用程序中带按钮的按钮已启动并且后台任务中处理按钮。
我见过敬酒,当从没有按钮的后台任务启动吐司时,会显示一条消息。
我需要知道的是,如果从后台任务启动带按钮的烤面包,如何处理按钮。
这可能吗?如果是这样如何?
这里是用在后台任务,以显示敬酒代码:
namespace BGtask
{
public sealed class BGTimerTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
var deferral = taskInstance.GetDeferral();
try
{
SendToast();
}
finally
{
// And finally release the deferral since we're done
deferral.Complete();
}
}
private void SendToast()
{
ToastContent content = new ToastContent()
{
Visual = new ToastVisual()
{
TitleText = new ToastText()
{
Text = "XYZ"
},
BodyTextLine1 = new ToastText()
{
Text = "Are you ready to do xyz?"
}
},
Actions = new ToastActionsCustom()
{
Inputs =
{
new ToastSelectionBox("selection")
{
Items =
{
new ToastSelectionBoxItem("1", "Yes"),
new ToastSelectionBoxItem("2", "Not Now"),
new ToastSelectionBoxItem("3", "Don't Show Again")
},
DefaultSelectionBoxItemId = "1"
}
},
Buttons =
{
new ToastButton("OK", new QueryString()
{
{ "action", "ok" },
}.ToString())
{
ActivationType = ToastActivationType.Background
},
}
}
};
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
}
}
}
告诉你尝试了一些假的代码? – Moumit
已添加代码,但问题是如何处理此面包中的按钮。 – Jack