Coding4Fun messagepromt取消按钮

时间:2013-11-30 21:23:06

标签: c# windows-phone-8 windows-phone messagebox

在我的应用程序中,我从Coding4Fun工具包中显示一个MessagePrompt,我显示如下:

            //Show Prompt
        var Prompt = new MessagePrompt
        {
            Title = "Delete Notes",
            Message = "Are you sure you want to remove all of your notes? This action is not reversible"
        };
        Prompt .IsCancelVisible = true;
        Prompt .Completed += deleteSubjectPrompt_Completed;
        Prompt .Show();

我处理这样的点击事件:

        private void deleteSubjectPrompt_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
    {
        //Handle
    }

当用户在提示符中按下ok按钮时运行的代码有效,但是当用户单击取消按钮时,相同的代码将执行为“ok”代码。我在这做错了什么?

1 个答案:

答案 0 :(得分:2)

deleteSubjectPrompt_Completed内,您必须检查e.PopUpResult

这样的事情:

switch (e.PopUpResult)
{
    case PopUpResult.Cancelled:
        break;
    case PopUpResult.NoResponse:
        break;
    case PopUpResult.Ok:
        break;
    case PopUpResult.UserDismissed:
        break;
    default:
        break;
}