DxMessageBox.Shown Event
Fires after the message box is displayed.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[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:
@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