加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-phone-7 – 如何在Windows Phone 7中创建确认对话框?

发布时间:2020-12-14 04:20:54 所属栏目:Windows 来源:网络整理
导读:如何在 Windows Phone 7中创建确认对话框? 我有一个应用程序,我可以删除项目,但当有人点击删除,我想让他一个确认对话框,他们可以点击’确认’或’中止’ 我怎么能这样做? 这是我使用的方法.为了获得更好的用户体验和一致性,请考虑使用“删除”和“取消”而
如何在 Windows Phone 7中创建确认对话框?

我有一个应用程序,我可以删除项目,但当有人点击删除,我想让他一个确认对话框,他们可以点击’确认’或’中止’

我怎么能这样做?

这是我使用的方法.为了获得更好的用户体验和一致性,请考虑使用“删除”和“取消”而不是“确认”或“中止”.
public static MessagePromptResult Show(string messageBoxText,string caption,string button1,string button2)
    {
        int? returned = null;
        using (var mre = new System.Threading.ManualResetEvent(false))
        {
            string[] buttons;
            if (button2 == null)
                buttons = new string[] { button1 };
            else
                buttons = new string[] { button1,button2 };

            Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
                caption,messageBoxText,buttons,// can choose which button has the focus
                Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None,// can play sounds
                result =>
                {
                    returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);
                    mre.Set(); // could have done it all without blocking
                },null);

            mre.WaitOne();
        }

        if (!returned.HasValue)
            return MessagePromptResult.None;
        else if (returned == 0)
            return MessagePromptResult.Button1;
        else if (returned == 1)
            return MessagePromptResult.Button2;
        else
            return MessagePromptResult.None;
    }

您需要将Microsoft.Xna.Framework.GamerServices的引用添加到您的项目中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读