Skip to content

Alert

Alert is a hairline-bordered ContentControl for a callout that needs the user’s attention. It is compositional: a consumer nests NaviusAlertTitle and NaviusAlertDescription (and any icon) inside a StackPanel as the single Content. Three severities ship: Default, Warning, and Destructive. Warning and destructive alerts take their border and title color from dedicated semantic theme tokens.

xmlns:alert="clr-namespace:Navius.Wpf.Ui.Alert;assembly=Navius.Wpf.Ui"
<alert:NaviusAlert Variant="Warning">
<StackPanel>
<alert:NaviusAlertTitle Content="Review recommended" />
<alert:NaviusAlertDescription Content="This configuration may reduce text contrast." />
</StackPanel>
</alert:NaviusAlert>
Property Type Default From Description
Variant NaviusAlertVariant Default NaviusAlert Default, Warning, or Destructive. Warning and destructive variants switch BorderBrush and Foreground to Navius.Warning and Navius.Destructive, respectively.
Content object - ContentControl (NaviusAlert) The alert body; nest NaviusAlertTitle/NaviusAlertDescription in a StackPanel.
Content object - ContentControl (NaviusAlertTitle) The title text. Inherits Foreground from the ancestor NaviusAlert, so it flips color with Variant automatically.
Content object - ContentControl (NaviusAlertDescription) The supplementary text. Foreground is a constant muted token regardless of Variant.

NaviusAlert overrides OnCreateAutomationPeer to return a NaviusAlertAutomationPeer (a FrameworkElementAutomationPeer), so the callout now reaches UI Automation as a real element instead of the bare visual tree a plain ContentControl exposes. The peer reports the Group control type (class name NaviusAlert) and maps Variant to a UIA live-region politeness: the informational Default variant announces Polite, while the urgent Warning and Destructive variants announce Assertive. That live setting is what gives a screen reader a signal to announce the alert. NaviusAlertTitle and NaviusAlertDescription still ship no peer of their own; their text content is read through the alert’s subtree. The unit suite exercises both the variant-driven brush switching (Alert_DefaultVariant_UsesNeutralBorder, Alert_WarningVariant_SwitchesBorderAndForegroundToWarning, and Alert_DestructiveVariant_SwitchesBorderAndForegroundToDestructive) and the automation peer (Alert_AutomationPeer_ReportsGroupControlType, Alert_AutomationPeer_DefaultVariant_AnnouncesPolite, and Alert_AutomationPeer_DestructiveVariant_AnnouncesAssertive) in tests/Navius.Wpf.Tests/UiDisplayItemsTests.cs.

  • NaviusAlertDescription keeps a constant muted foreground regardless of Variant; the web contract flips the description color with severity too. This is a deliberate simplification: a muted secondary line reads clearly against either the default or destructive title color without adding a second destructive-text-on-destructive-title legibility question.
  • Warning is a WPF semantic extension backed by the Navius.Warning and Navius.WarningForeground theme tokens. Success and Info variants do not ship because the token set does not define those semantic roles.