Back to Devexpress

DxMessageBox.Shown Event

blazor-devexpress-dot-blazor-dot-dxmessagebox-10b23470.md

latest1.4 KB
Original Source

DxMessageBox.Shown Event

Fires after the message box is displayed.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public EventCallback Shown { get; set; }

Remarks

Handle the Shown event to perform actions after the message box appears. The following code sample hides the message box 3 seconds after it is displayed:

razor
@using System.Timers;

<DxButton Text="Show Alert" Click="@(() => MessageBoxVisible = true)" />
<DxMessageBox @bind-Visible="MessageBoxVisible" 
              Title="Alert" 
              Text="I'm an alert that hides in 3 seconds" 
              Shown="@Shown" />

@code {
    bool MessageBoxVisible { get; set; } = false;
    static Timer mbTimer;

    void Shown() {
        mbTimer = new Timer(3000);
        mbTimer.Elapsed += OnTimedEvent;
        mbTimer.Enabled = true;
    }

    void OnTimedEvent(Object source, ElapsedEventArgs e) {
        MessageBoxVisible = false;
        mbTimer.Stop();
        mbTimer.Dispose();
        InvokeAsync(StateHasChanged);
    }
}

See Also

DxMessageBox Class

DxMessageBox Members

DevExpress.Blazor Namespace