Skip to content

WindowResultContext<T>

Namespace: Hex1b

Assembly: Hex1b.dll

Provides context for window result callbacks when a dialog closes with a typed result.

csharp
public sealed class WindowResultContext<T>

Inheritance

ObjectWindowResultContext<T>

Properties

IsCancelled

Whether the dialog was cancelled (closed without providing a result). When true, should not be used.

Returns: Boolean

csharp
public bool IsCancelled { get; }

Value

The result value provided via . This is the default value of T when is true.

Returns: <T>

csharp
public T? Value { get; }

Window

The window entry that was closed.

Returns: WindowEntry

csharp
public WindowEntry Window { get; }

Windows

Convenience accessor for the window manager. Use this to open additional windows or perform other window operations.

Returns: WindowManager

csharp
public WindowManager Windows { get; }

Remarks

WindowResultContext is passed to OnResult callbacks when a window closes, providing access to the result value and cancellation state.

A result is considered cancelled when the window is closed without calling

  • for example, via the close button or Escape key.

Examples

csharp
e.Windows.Window(w => w.VStack(v => [
    v.Text("Delete this item?"),
    v.HStack(h => [
        h.Button("Yes").OnClick(_ => w.Window.CloseWithResult(true)),
        h.Button("No").OnClick(_ => w.Window.CloseWithResult(false))
    ])
]))
.Title("Confirm Delete")
.Modal()
.OnResult(result => {
    if (!result.IsCancelled && result.Value)
    {
        DeleteItem();
    }
})
.Open(e.Windows);

Released under the MIT License.