Back to Devexpress

DxDropDown.CloseAsync(CancellationToken) Method

blazor-devexpress-dot-blazor-dot-dxdropdown-dot-closeasync-x28-system-dot-threading-dot-cancellationtoken-x29.md

latest2.7 KB
Original Source

DxDropDown.CloseAsync(CancellationToken) Method

Asynchronously closes the drop-down window.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public Task<bool> CloseAsync(
    CancellationToken token = default(CancellationToken)
)

Optional Parameters

NameTypeDefaultDescription
tokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
Task<Boolean>

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

|

Remarks

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

razor
<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:

ShowingFires before the window is displayed and allows you to cancel this action.ShownFires after the window is displayed.ClosingFires before the window is closed and allows you to cancel this action.ClosedFires after the window is closed.

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

See Also

DxDropDown Class

DxDropDown Members

DevExpress.Blazor Namespace