Class Dialog
A modal dialog window with buttons across the bottom. When a button is pressed, Result is set to the button's index (0-based).
public class Dialog : Dialog<int>, IDisposable, ISupportInitializeNotification, ISupportInitialize, IRunnable<int>, IRunnable, IDesignable
- Inheritance
-
Dialog
- Implements
- Derived
- Inherited Members
- Extension Methods
Examples
Dialog dialog = new () { Title = "Confirm" };
dialog.AddButton (new () { Title = "_Cancel" });
dialog.AddButton (new () { Title = "_Ok" });
Label label = new () { Text = "Are you sure?" };
dialog.Add (label);
Application.Run (dialog);
if (dialog.Result == 1) // OK button (second button, index 1)
{
// User clicked OK
}
Remarks
This is the standard dialog class for simple button-index-based results. For dialogs that need to return custom result types, derive from Dialog<TResult> instead.
By default, Dialog is centered with Auto(DimAutoStyle, Dim?, Dim?) sizing and uses the Dialog color scheme when running.
To run modally, pass the dialog to Run(IRunnable, Func<Exception, bool>?). The dialog executes until terminated by QuitKey (Esc by default), a press of one of the Buttons, or if any subview receives the Accept command and does not handle it.
Buttons are added via AddButton(Button) or the Buttons property. The last button added becomes the default (IsDefault). Button alignment is controlled by ButtonAlignment and ButtonAlignmentModes.
Constructors
Properties
- DefaultBorderStyle
The default border style for new Dialog instances. Can be configured via ConfigurationManager and theme files.
- DefaultButtonAlignment
The default button alignment for new Dialog instances. Can be configured via theme files.
- DefaultButtonAlignmentModes
The default button alignment modes for new Dialog instances. Can be configured via theme files.
- DefaultShadow
The default shadow style for new Dialog instances. Can be configured via theme files.
- Result
Gets or sets the result of the dialog, indicating which button was pressed.
Methods
- OnAccepting(CommandEventArgs)
Overrides the default Accepting behavior to handle Dialog Button presses.