Table of Contents

Class TwDialog

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Renders the backdrop, positioning, and chrome (header, title, close button) around dialog content shown via ITwDialogService.

public class TwDialog : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, IAsyncDisposable
Inheritance
TwDialog
Implements
Inherited Members

Remarks

This component is rendered internally by TwDialogProvider for each active dialog and is not typically instantiated directly by consumers.

Constructors

TwDialog()

public TwDialog()

Properties

Reference

Gets or sets the dialog reference this chrome renders content for.

[Parameter]
[EditorRequired]
public ITwDialogReference Reference { get; set; }

Property Value

ITwDialogReference

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

DisposeAsync()

Releases the JS-side Tab focus trap registered for this dialog's surface.

public ValueTask DisposeAsync()

Returns

ValueTask

OnAfterRenderAsync(bool)

Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time OnAfterRender(bool) has been invoked on this component instance; otherwise false.

Returns

Task

A Task representing any asynchronous operation.

Remarks

The OnAfterRender(bool) and OnAfterRenderAsync(bool) lifecycle methods are useful for performing interop, or interacting with values received from @ref. Use the firstRender parameter to ensure that initialization work is only performed once.

OnParametersSet()

Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.

protected override void OnParametersSet()

Remarks

If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.