-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Background and motivation
Issue #5795 suggests getting more MessageBoxButton
and MessageBoxResult
values available and bringing Wpf repository more in sync with what is available in WinForms repository.
It will also make it easier to migrate from WinForms to WPF that you can practically directly make the same call to show a MessageBox in WPF as in WinForms.
Both repositories are calling into the same MessageBox
function in Windows, so it should not be a technical problem to handle this.
API Proposal
Extend MessageBoxButton
and MessageBoxResult
enumerations
Add AbortRetryIgnore
, RetryCancel
and CancelTryContinue
to the MessageBoxButton
enumeration:
namespace System.Windows
{
public enum MessageBoxButton
{
OK = 0,
OKCancel = 1,
+ AbortRetryIgnore = 2,
YesNoCancel = 3,
YesNo = 4,
+ RetryCancel = 5,
+ CancelTryContinue = 6,
}
}
Also add Abort
, Retry
, Ignore
, TryAgain
and Continue
to the MessageBoxResult
enumeration:
namespace System.Windows
{
public enum MessageBoxResult
{
None = 0,
OK = 1,
Cancel = 2,
+ Abort = 3,
+ Retry = 4,
+ Ignore = 5,
Yes = 6,
No = 7,
+ TryAgain = 10,
+ Continue = 11,
}
}
API Usage
// Call the MessageBox.Show with additional parameters
MessageBoxResult result = MessageBox.Show("Operation timed out. What would you like to do?",
"My application",
MessageBoxButton.RetryCancel,
MessageBoxIcon.Question,
MessageBoxResult.Retry);
if (result == MessageBoxResult.Retry)
{
/// Perfom code to retry operation
}
else
{
// Log cancel request and exit
}
Alternative Designs
No response
Risks
In connection with the extra enumeration values, I don't see a risk, since the values already exist in the underlying Windows API (1).