首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >后台通知+ Windows 8

后台通知+ Windows 8
EN

Stack Overflow用户
提问于 2013-02-13 22:52:19
回答 1查看 91关注 0票数 0

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

我该怎么检查呢?

代码语言:javascript
复制
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();
        }

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-02-14 00:07:07

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14856271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档