我有一个简单的Windows 8应用程序,它在计时器达到0时显示通知。现在,我希望这些通知只在应用程序处于后台时显示。
我该怎么检查呢?
protected void Back_Tick(object sender, object e)
{
if (stageSequence.Current.RemainningTime == TimeSpan.Zero)
{
if(stageSequence.MoveNext() == true)
{
var typeOfNotification = TypeOfNotification.EndOfStage;
// Check If it is on background
ToastAlarmNotification(lblStage.Text, typeOfNotification);
lblStage.Text = stageSequence.Current.Name;
lblTime.Text = stageSequence.Current.RemainningTime.ToString();
mediaElementEndOfStage.Play();
}
else
{
var typeOfNotification = TypeOfNotification.EndOfStage;
dispatcherTimer.Stop();
// Check If it is on background
ToastAlarmNotification(lblStage.Text, typeOfNotification);
typeOfNotification = TypeOfNotification.EndOfList;
ToastAlarmNotification(lblStage.Text, typeOfNotification);
mediaElementFinal.Play();
return;
}
}
stageSequence.Current.RemainningTime = stageSequence.Current.RemainningTime.Subtract(TimeSpan.FromSeconds(1));
lblTime.Text = stageSequence.Current.RemainningTime.ToString();
}谢谢
发布于 2013-02-14 00:07:07
您可以在UI线程中注册CoreWindow.VisibilityChanged事件并存储VisibilityChangedEventArgs.Visible值。
https://stackoverflow.com/questions/14856271
复制相似问题