Windows phone 8自定义消息框问题

时间:2014-07-28 22:27:07

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

我正在使用Microsoft.Phone.Controls.Toolkit程序集中的自定义消息框。

我在这里对被解雇的事件有一个问题。

         var emControl = new EmailAddressUserControl();
         var messageBox = new CustomMessageBox()
         {
             IsFullScreen = false,
             Caption = AppResources.AppResources.SettingTitle4,
             LeftButtonContent = AppResources.AppResources.Ok,
             RightButtonContent = AppResources.AppResources.Cancel,
             Content = emControl
         };
        messageBox.Dismissed += async (s1, e1) =>
        {
            switch (e1.Result)
            {
                case CustomMessageBoxResult.LeftButton:
                    bool isValidEmail = emControl.finishButton_Click();
                    if (isValidEmail)
                    {
                        string TempVarUserEmail = SharedProperties.EmailId.Value;
                        SharedProperties.EmailId.Value = emControl.getUserEmail();
                        ifEmailUpdate = await UpdateEmail();
                        if (ifEmailUpdate)
                        {
                            _instance.subTbEmailAddr.Text = SharedProperties.EmailId.Value;

                        }
                        else
                        {
                            // restoring user email address if updation failed.
                            SharedProperties.EmailId.Value = TempVarUserEmail;
                            MessageBox.Show("Email updation failed. Try again later", "Email update failed!!!", MessageBoxButton.OK);

                        }
                    }
                    else
                    {

                            MessageBox.Show("Please enter valid Email address", "Invalid email address!!!", MessageBoxButton.OK);

                    }
                    break;
            }
        };

我的EmailAddressUserControl中有一个文本框,它基本上是电子邮件地址,当我点击消息框上的确定时,它会检查电子邮件地址的有效性...

我现在遇到的问题是,如果它无效,它将在else条件下显示常规消息框,当我点击该消息框上的OK时,即使自定义消息框也被取消。

有没有办法覆盖这个?即使单击确定后,我仍然可以显示消息吗?我知道我正在验证OK按钮单击的电子邮件地址,它是在被解雇的事件处理程序中,我认为这是一个不好的方法。

我对任何想法和批评持开放态度。

1 个答案:

答案 0 :(得分:0)

我不是百分百肯定我得到了你的要求。如果用户在“无效的电子邮件地址”消息框中单击“确定”,您是否可以再次打开自定义消息框?

        MessageBoxResult msg = MessageBox.Show("Please enter valid Email address", "Invalid email address!", MessageBoxButton.OK);
        if (msg == MessageBoxResult.OK)
        {
            //OK Clicked
            //Open up the custom messsage box here again
        }