@page "/compomessagebox"
@inject IDialogService DialogService;
@rendermode RenderMode.InteractiveServer
MessageBox
The FluentMessageBox
is a dialog that is used to display information with a specific intent to the user.
It uses the DialogService
to display the dialog.
Message Service
Success
Warning
Error
Information
Confirmation
Long Information
Custom
Last result: @(canceled == null ? "" : (canceled == true ? "❎ Canceled" : "✅ OK"))
@code {
bool? canceled;
async Task ShowSuccessAsync()
{
var dialog = await DialogService.ShowSuccessAsync("The action was a success");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowWarningAsync()
{
var dialog = await DialogService.ShowWarningAsync("The action was a warning");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowErrorAsync()
{
var dialog = await DialogService.ShowErrorAsync("The action was a error");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowInformationAsync()
{
var dialog = await DialogService.ShowInfoAsync("The action was a information");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowConfirmationAsync()
{
var dialog = await DialogService.ShowConfirmationAsync("Do you like Blazor?", "Sure!", "Nope!");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowLongInformationAsync()
{
var dialog = await DialogService.ShowInfoAsync("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum");
var result = await dialog.Result;
canceled = result.Cancelled;
}
async Task ShowCustomMessageBoxAsync()
{
var dialog = await DialogService.ShowMessageBoxAsync(new DialogParameters()
{
Content = new MessageBoxContent
{
Title = "My title",
MarkupMessage = new MarkupString("My customized message"),
Icon = new Icons.Regular.Size24.Games(),
IconColor = Color.Success
},
PrimaryAction = "Plus",
SecondaryAction = "Minus",
Width = "300px"
});
var result = await dialog.Result;
canceled = result.Cancelled;
}
}