Class Dialog<TResult>
A Dialog paired with a Task<TResult>-returning show/close API - the
general-purpose modal-hosting primitive most callers use directly (or through MessageBox's
convenience methods). Not a UIElement itself; wraps a plain Dialog instance,
which is what's actually added to a Canvas and themed - a closed generic type's runtime
name embeds its type argument, so an open-generic Style TargetType="Dialog" entry would never
match a Dialog<TResult> if it were a UIElement itself.
public sealed class Dialog<TResult>
Type Parameters
TResultThe type of value this dialog closes with.
- Inheritance
-
Dialog<TResult>
- Inherited Members
- Extension Methods
Constructors
Dialog()
Initializes a new instance of the Dialog<TResult> class.
public Dialog()
Properties
Content
Gets or sets the content this dialog displays.
public UIElement? Content { get; set; }
Property Value
IsOpen
Gets a value indicating whether this dialog is currently shown.
public bool IsOpen { get; }
Property Value
Methods
Close(TResult?)
Closes this dialog with result, completing the task ShowAsync(Canvas)
returned. A no-op if this dialog isn't currently open.
public void Close(TResult? result)
Parameters
resultTResultThe result to complete the ShowAsync(Canvas) task with.
ShowAsync(Canvas)
Shows this dialog as a modal overlay on canvas and returns a task that completes
with whatever value Close(TResult?) is called with (or default, if
dismissed via Escape). Calling this again while already open returns the same in-flight task instead
of showing a second copy.
public Task<TResult?> ShowAsync(Canvas canvas)
Parameters
canvasCanvasThe canvas to show this dialog on.
Returns
- Task<TResult>
A task that completes with the dialog's result once it closes.