- Notifications
You must be signed in to change notification settings - Fork1.2k
Description
Background and motivation
Issue#5795 suggests getting moreMessageBoxButton
andMessageBoxResult
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 sameMessageBox
function in Windows, so it should not be a technical problem to handle this.
API Proposal
ExtendMessageBoxButton
andMessageBoxResult
enumerations
AddAbortRetryIgnore
,RetryCancel
andCancelTryContinue
to theMessageBoxButton
enumeration:
namespace System.Windows{ public enum MessageBoxButton { OK = 0, OKCancel = 1,+ AbortRetryIgnore = 2, YesNoCancel = 3, YesNo = 4,+ RetryCancel = 5,+ CancelTryContinue = 6, }}
Also addAbort
,Retry
,Ignore
,TryAgain
andContinue
to theMessageBoxResult
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 parametersMessageBoxResultresult=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).