I am using custom message box from Microsoft.Phone.Controls.Toolkit assembly.
I am have an issue here with respect to the Dismissed event.
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;
}
};
I have a textbox in my EmailAddressUserControl which basically takes email address and when i click on OK on the message box it checks the validity of the email address...
The problem i have right now is that, if its not valid, it will show up the regular message box in the else condition and when i click on OK on that messatge box, even the custom message box is dismissed.
Is there a way to override this ? Can i have the message to still be present even after clicking on OK? I know i am validating the email address on the OK button click and it is in the dismissed event handler, i think its a bad way of doing it.
I am open to any ideas and criticisms.
I'm not 100% sure I got what you asked. Can you just open the custom message box again if the user clicks OK on the "Invalid email address" message box?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.