我想有一個時間推出舉杯顯示的過程按鈕觸發顯示與按鍵舉杯後臺任務。 「你準備好做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