Skip to main content

DxDropDown.ShowAsync(CancellationToken) Method

Asynchronously shows the drop-down window.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task<bool> ShowAsync(
    CancellationToken token = default(CancellationToken)
)

Optional Parameters

Name Type Default Description
token CancellationToken null

An object that propagates a cancellation notification.

Returns

Type Description
Task<Boolean>

An asynchronous operation that shows the window. The operation returns true if the operation is successful; otherwise, false.’

Remarks

Call the ShowAsync and CloseAsync methods to show and close the drop-down window asynchronously.

If you call the ShowAsync method before the window is initialized, the operation returns false. You can use the IsInitialized property to check the initialization state. Run the InitializedTask task to wait until the drop-down window is initialized.

<DxButton Text="Show" Click="ShowWindow" />
<DxButton Text="Hide" Click="HideWindow" />

<DxDropDown @ref="ddWindow"
            Width="400"
            BodyText="Lorem ipsum dolor sit amet, consectetur adipiscing elit.">
</DxDropDown>

@code {
    DxDropDown ddWindow { get; set; }

    async Task ShowWindow(MouseEventArgs args) {
        if (ddWindow.IsInitialized)
            await ddWindow.ShowAsync();
        else {
            await ddWindow.InitializedTask;
            await ddWindow.ShowAsync();
        }
    }
    async Task HideWindow(MouseEventArgs args) {
        await ddWindow.CloseAsync();
    }
}

You can handle the following events related to ShowAsync and CloseAsync methods:

Showing - Fires before the window is displayed and allows you to cancel this action.
Shown - Fires after the window is displayed.
Closing - Fires before the window is closed and allows you to cancel this action.
Closed - Fires after the window is closed.

To show and close the drop-down window synchronously, implement two-way binding for the IsOpen property.

See Also