Return Results from a DialogBox in WPF

Before a dialog box closes, its DialogResult property should be set with a Nullable<(Of <(T>)>) Boolean that indicates how the user closed the dialog box. This value is returned by ShowDialog to allow client code to determine how the dialog box was closed and, consequently, how to process the result.

DialogBoxWithResult dialogBoxWithResult = new DialogBoxWithResult();
// Open dialog box and retrieve dialog result when ShowDialog returns
bool? dialogResult = dialogBoxWithResult.ShowDialog();
switch (dialogResult)
{
case true:
// User accepted dialog box
break;
case false:
// User canceled dialog box
break;
default:
// Indeterminate
break;
}