Notification
Namespace: Hex1b
Assembly: Hex1b.dll
Represents a notification that can be displayed to the user. Notifications are mutable state objects - modify properties directly and the UI will update.
public sealed class NotificationInheritance
Object → Notification
Constructors
Notification(string, string?)
Creates a new notification with the specified title.
Parameters:
public Notification(string title, string? body = null)Properties
Body
Optional body text with additional details.
Returns: String
public string? Body { get; set; }CreatedAt
When this notification was created.
Returns: DateTimeOffset
public DateTimeOffset CreatedAt { get; }PrimaryActionValue
The primary action button. Displayed as the main button on the notification.
Returns: NotificationAction
public NotificationAction? PrimaryActionValue { get; }SecondaryActions
Secondary actions. Displayed in a dropdown menu next to the primary action.
Returns: IReadOnlyList<NotificationAction>
public IReadOnlyList<NotificationAction> SecondaryActions { get; }TimeoutDuration
Optional timeout after which the notification hides from floating view. The notification remains in the notification panel until explicitly dismissed. If null, the notification floats indefinitely until dismissed.
Returns: Nullable<TimeSpan>
public TimeSpan? TimeoutDuration { get; set; }Title
The notification title. Displayed prominently.
Returns: String
public string Title { get; set; }Methods
OnDismiss(Func<NotificationEventContext, Task>)
Sets the handler invoked when this notification is dismissed.
Parameters:
handler(Func<NotificationEventContext, Task>): The async handler.
Returns: Notification
This notification for fluent chaining.
public Notification OnDismiss(Func<NotificationEventContext, Task> handler)OnTimeout(Func<NotificationEventContext, Task>)
Sets the handler invoked when this notification times out. Timeout hides the notification from floating view but keeps it in the panel.
Parameters:
handler(Func<NotificationEventContext, Task>): The async handler.
Returns: Notification
This notification for fluent chaining.
public Notification OnTimeout(Func<NotificationEventContext, Task> handler)PrimaryAction(string, Func<NotificationActionContext, Task>)
Sets the primary action for this notification.
Parameters:
label(String): The button label.handler(Func<NotificationActionContext, Task>): The async handler invoked when the action is triggered.
Returns: Notification
This notification for fluent chaining.
public Notification PrimaryAction(string label, Func<NotificationActionContext, Task> handler)SecondaryAction(string, Func<NotificationActionContext, Task>)
Adds a secondary action to this notification. Secondary actions appear in a dropdown menu next to the primary action.
Parameters:
label(String): The button label.handler(Func<NotificationActionContext, Task>): The async handler invoked when the action is triggered.
Returns: Notification
This notification for fluent chaining.
public Notification SecondaryAction(string label, Func<NotificationActionContext, Task> handler)Timeout(TimeSpan)
Sets the timeout duration for this notification. After the timeout, the notification hides from floating view but remains in the notification panel.
Parameters:
duration(TimeSpan): The duration after which the notification hides from floating view.
Returns: Notification
This notification for fluent chaining.
public Notification Timeout(TimeSpan duration)Remarks
Notifications have a lifecycle: they are posted to a , appear as floating overlays, optionally time out (hiding from floating view but remaining in the notification panel), and can be dismissed entirely.
Use the fluent API to configure actions and lifecycle handlers:
var notification = new Notification("File saved", "document.txt saved successfully")
.Timeout(TimeSpan.FromSeconds(5))
.PrimaryAction("View", async ctx => await OpenFileAsync())
.SecondaryAction("Undo", async ctx => await UndoSaveAsync())
.OnDismiss(async ctx => await CleanupAsync());
e.Notifications.Post(notification);