Elements
Alert
A dialog-based alert component that displays a title, message, and dismiss button. Extends Dialog functionality.
Constructor
new Alert("Warning", "This is an alert message");Examples
ViewModel-Triggered Alerts
Show alerts based on ViewModel state and actions:
// Error alert from ViewModel
new Alert("Error", "Invalid username or password")
.BindOpen(ViewModel.ShowLoginError);
// Success confirmation
new Alert("Success", "Document saved successfully")
.BindOpen(ViewModel.ShowSaveSuccess);
// Warning with action
new Alert("Warning", "Unsaved changes will be lost")
.BindOpen(ViewModel.ShowUnsavedWarning);Reactive Alert Messages
Alert content can be bound to ViewModel properties:
// Dynamic error messages
var errorAlert = new Alert("Error", "")
.BindOpen(ViewModel.ErrorMessage.Select(msg => !string.IsNullOrEmpty(msg)));
// Note: Alert constructor requires fixed strings, but you can create
// custom alert dialogs using Dialog + DialogContent for reactive contentForm Validation Alerts
Common alert patterns for form validation:
// Validation error alert
new Alert("Validation Error", "Please check the required fields")
.BindOpen(ViewModel.HasValidationErrors)
.OnClose(() => ViewModel.ClearValidationErrors());
// Network error alert
new Alert("Connection Error", "Unable to connect to server")
.BindOpen(ViewModel.HasNetworkError);Properties
| Prop | Type | Default |
|---|---|---|
title | string | - |
message | string | - |
children? | IElement[] | [] |
open? | bool | false |
disabled? | bool | false |
visible? | bool | true |
name? | string | "" |
pickingMode? | PickingMode | PickingMode.Position |
Methods
| Prop | Type | Default |
|---|---|---|
Open? | (bool = true) => Alert | - |
Close? | () => Alert | - |
GetOpen? | () => bool | - |
BindOpen? | (Observable<bool>) => Alert | - |
OnClose? | (Action) => Alert | - |
Disabled? | (bool = true) => Alert | - |
GetDisabled? | () => bool | - |
BindDisabled? | (Observable<bool>) => Alert | - |
Visible? | (bool) => Alert | - |
GetVisible? | () => bool | - |
BindVisible? | (Observable<bool>) => Alert | - |
ClassName? | (string, bool = true) => Alert | - |
BindClassName? | (string, Observable<bool>) => Alert | - |
StyleSheet? | (StyleSheet) => Alert or (string) => Alert | - |
Flex? | (int flexGrow, int flexShrink = 0) => Alert | - |
JustifyContent? | (Justify) => Alert | - |
AlignItems? | (Align) => Alert | - |
BindChildren? | <TChild>(Observable<TChild[]>, Func<TChild, IElement>) => Alert | - |
Alert extends Dialog which extends Group which extends BaseElement.