Table of Contents

Class Dialog

Namespace
Loehnert.Controls.Dialogs
Assembly
Loehnert.Controls.dll

Represents a dialog.

public class Dialog
Inheritance
Dialog
Inherited Members

Constructors

Dialog(IDialogCoordinator, DialogViewModel)

Initializes a new instance of the Dialog class.

public Dialog(IDialogCoordinator dialogCoordinator, DialogViewModel dialogViewModel)

Parameters

dialogCoordinator IDialogCoordinator

Coordinator for dialogs.

dialogViewModel DialogViewModel

View model of the dialog.

Exceptions

ArgumentNullException

Thrown when an argument is null.

Dialog(IDialogCoordinator, DialogViewModel, MetroDialogSettings)

Initializes a new instance of the Dialog class.

public Dialog(IDialogCoordinator dialogCoordinator, DialogViewModel dialogViewModel, MetroDialogSettings settings)

Parameters

dialogCoordinator IDialogCoordinator

Coordinator for dialogs.

dialogViewModel DialogViewModel

View model of the dialog.

settings MetroDialogSettings

Optional metro dialog settings.

Exceptions

ArgumentNullException

Thrown when dialogCoordinator or dialogViewModel is null.

Properties

Context

Gets or sets the context in which the dialog is shown, this is required for external windows, for example in dialog windows. By default, the IMainWindow view model is used.

public object Context { get; set; }

Property Value

object

IsFullScreen

Gets or sets a value indicating whether the dialog should be in full screen mode.

public bool IsFullScreen { get; set; }

Property Value

bool

ThrowExceptionOnCancel

Gets or sets a value indicating whether a exception should be thrown at cancellation.

public bool ThrowExceptionOnCancel { get; set; }

Property Value

bool

Methods

Close(string)

Closes the dialog.

public virtual DialogResult Close(string key)

Parameters

key string

The close reason key, see CloseReasonKey.

Returns

DialogResult

A dialog result.

Show()

Shows the dialog on the associated Context.

public virtual DialogResult Show()

Returns

DialogResult

The result of the dialog.

Exceptions

InvalidOperationException

Thrown if the dialog has already been closed.

OperationCanceledException

Thrown if the user presses the cancel button while ThrowExceptionOnCancel is true.

Show(CancellationToken)

Shows the dialog on the associated Context.

public virtual DialogResult Show(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

DialogResult

The result of the dialog.

Exceptions

InvalidOperationException

Thrown if the dialog has already been closed.

OperationCanceledException

Thrown if the user presses the cancel button or if the operation is canceled via a cancellationToken, and ThrowExceptionOnCancel is true.

ShowAsync()

Shows the dialog on the Context.

public virtual Task<DialogResult> ShowAsync()

Returns

Task<DialogResult>

The task with dialog result.

Exceptions

InvalidOperationException

Thrown when the dialog has already been closed.

OperationCanceledException

Thrown if the user presses the cancel button and ThrowExceptionOnCancel is true.

ShowAsync(CancellationToken)

Asynchronously shows the dialog on the associated Context.

public virtual Task<DialogResult> ShowAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<DialogResult>

A task that represents the asynchronous operation. The task result contains the dialog result.

Exceptions

InvalidOperationException

Thrown if the dialog has already been closed.

OperationCanceledException

Thrown if the user presses the cancel button or if the operation is canceled via a cancellationToken, and ThrowExceptionOnCancel is true.