Skip to content
Cole Campbell edited this page Mar 3, 2018 · 2 revisions

Ultraviolet Framework 1.3 added support for the creation of modal dialog boxes.

Creating a Modal

New modal dialogs must inherit from the Modal abstract class found in the Ultraviolet.Presentation namespace. Each modal is associated with an instance of UIScreen; the screen's view defines the layout of the modal. The Modal class requires that this screen be exposed by implementing the abstract Screen property.

public partial class MyModal : Modal
{
    public MyModal()
    {
        Screen = new MyModalScreen();
    }

    public override UIScreen Screen { get; }
}

Every modal has an associated value called its dialog result, which is set when the modal is closed. This value, exposed by the DialogResult property of the modal instance, indicates whether the modal's operation completed successfully, failed, or was cancelled. You can specify a modal's dialog result by closing the modal using its Close() method, usually from within the view model of the modal's screen.

Using a Modal

A modal is opened using one of the ShowDialog() or ShowDialogAsync() static methods defined by the Modal class. Use ShowDialogAsync() when you need to respond to the dialog result; it will return a ModalTask<Boolean?> which will complete when the dialog is closed.

Modal.ShowDialogAsync(myModalInstance).ContinueWith(result =>
{
    // handle dialog result
});

If you use ShowDialog(), no ModalTask is returned, and your code will not be able to respond to the modal's dialog result.

Clone this wiki locally