Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxWindow.ShowAsync(CancellationToken) Method

Asynchronously shows the Window.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
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.

#Remarks

Call the ShowAsync and CloseAsync methods to show and close the Window asynchronously. Make sure the component has been initialized before you call the ShowAsync method. Use the IsInitialized property to check the initialization state.

Razor
@inject IJSRuntime JsRuntime

<DxButton RenderStyle="ButtonRenderStyle.Primary" Text="Show" Click="ShowClick" />

<DxWindow @bind-Visible="@WindowVisible"
         HeaderText="Header"
         BodyText="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel
             nisi blandit tincidunt vel efficitur purus. Nunc nec turpis tempus, accumsan orci auctor,
             imperdiet mauris. Fusce id purus magna."
         ShowFooter="true"
         @ref="Window">
    <FooterTemplate>
        <DxButton RenderStyle="ButtonRenderStyle.Primary" Text="Close" Click="CloseClick" />
    </FooterTemplate>
</DxWindow>

@code {
    DxWindow Window;
    bool WindowVisible { get; set; } = false;

    async Task ShowClick(MouseEventArgs args)
    {
        if (Window.IsInitialized)
            await Window.ShowAsync();
        else
            await JsRuntime.InvokeVoidAsync("alert", "The component has not been initialized yet. Please try later.");
    }

    async Task CloseClick(MouseEventArgs args)
    {
        await Window.CloseAsync();
    }
}

You can handle the following events related to the 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 Window synchronously, implement two-way binding for the Visible property.

See Also