Hi every body
i devoloped a custom MessageBox Class to use it in other application, and i made the application
and it work fine except in one place and it's Window_Closing handler.
If i replce the custom MessageBox with the standard MessageBox it works when i use my custom message box it doesn't and i don't know why and here's asnapshot of my code
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
i had stepped my code as u suggested and i made a break at the Fn
public static MessageBoxResult Show(string msg, string title, MessageBoxButton butsta)
if i made butsta=YesNo then every thing is fine and it work,but if i made butsta=YesNoCancel the step work fine untill reach the statement
it execute it but doesn't show the dialog and immediately go to the next statement
return _msgboxresult; //the default value for _msgboxresult is None
/// Fn to confirm the user if data saving required befor closing the application
private void Terminate(/*System.ComponentModel.CancelEventArgs ee*/)
if (savingRequest == true)
switch (MessageBoxCustomized.Show("Do you want to save changes", "Saving Attention", MessageBoxButton.YesNoCancel))
// ee.Cancel = true;
else //if no saving required
switch (MessageBoxCustomized.Show("Are you Sure to exit ?", "Exit Application", MessageBoxButton.YesNo))
case MessageBoxResult.Yes: Application.Current.Shutdown(); break;
case MessageBoxResult.No: break;
and it works perfect but i want to know why "The MessgeBoxCustomized window doesn't work only in window closing event handler" is there any technical problem!
Hey people i have found the answer why "The MessgeBoxCustomized window doesn't work only in window closing event handler" in stackoverflow forum and here's the context literal
"The Closing event cannot be canceled if you call Application.Current.Shutdown(). Just call the Window.Close() method instead, which will give you a chance to veto the close operation. Once all your program's windows have closed the application will shutdown automatically."