0

我有一个简单的 Windows 8 应用程序,它在计时器达到 0 时显示通知。现在我希望这些通知仅在 APP 处于后台时显示。

我该如何检查?

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();
        }

谢谢

4

1 回答 1

0

您可以在 UI 线程中注册CoreWindow.VisibilityChangedVisibilityChangedEventArgs.Visible事件并存储值。

于 2013-02-13T16:07:06.857 回答