【问题标题】:Windows Phone App Exit NotificationWindows Phone 应用退出通知
【发布时间】:2014-07-09 09:53:04
【问题描述】:

我在一个应用中看到了这个非常酷的功能。目前我正在显示 MessageBox 以询问用户是否要退出应用程序。但如图所示,此 ExitNotification 像推送通知一样出现在页面顶部,如果用户再次按下后退按钮,应用程序将退出。 请帮助我如何创建类似的通知。谢谢。

【问题讨论】:

  • 我的回答有帮助吗..?

标签: c# xaml windows-phone-8 windows-phone windows-phone-8.1


【解决方案1】:

为此,您可以使用PopUp Control。您可以在应用程序页面的LayoutRoot 网格顶部显示弹出窗口。对于创建弹出窗口,您可以从这里获得参考 How to use Pop-Ups in Windows Phone

【讨论】:

    【解决方案2】:

    那个控件是来自 Coding4fun 工具包的ToastPrompt。要开始使用 ToastPrompt,首先添加对 Coding4Fun.Phone.Controls.dll 程序集的引用。

    然后在方法OnBackKeyPress 中从Here 中创建ToastPrrompt

    protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (!isExit)
            {
                isExit = true;
                var toast = new ToastPrompt();
                toast.Message = "Press back again to exit?";
                toast.MillisecondsUntilHidden = 3000;
                toast.Completed += (o, ex) => { isExit = false; };
                toast.Show();
                e.Cancel = true;
            }
            else
            {
                NavigationService.RemoveBackEntry();
            }
        }
    

    注意:您必须创建bool variable as isExit & MillisecondsUntilHidden 是显示弹出窗口的时间计数,以毫秒为单位。

    感谢 Coding4Fun 伙计们

    【讨论】:

    • 如果你想在第二次按下后退按钮时终止,请在 NavigationService.RemoveBackEntry(); 之前写 Application.Current.Terminate();
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多