diff --git a/src/MainDemo.Wpf/Alerts.xaml b/src/MainDemo.Wpf/Alerts.xaml
new file mode 100644
index 0000000000..9dcb7a7b53
--- /dev/null
+++ b/src/MainDemo.Wpf/Alerts.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MainDemo.Wpf/Alerts.xaml.cs b/src/MainDemo.Wpf/Alerts.xaml.cs
new file mode 100644
index 0000000000..38deaf551f
--- /dev/null
+++ b/src/MainDemo.Wpf/Alerts.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesignDemo;
+
+public partial class Alerts
+{
+ public Alerts() => InitializeComponent();
+}
diff --git a/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs b/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
index 391faf8a57..c023dd60f8 100644
--- a/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
+++ b/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
@@ -255,6 +255,15 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Disabled
};
+ yield return new DemoItem(
+ "Alert",
+ typeof(Alerts),
+ [
+ DocumentationLink.DemoPageLink(),
+ DocumentationLink.StyleLink("Alert"),
+ DocumentationLink.ApiLink()
+ ]);
+
yield return new DemoItem(
"Icons",
typeof(IconPack),
diff --git a/src/MaterialDesign3.Demo.Wpf/Alerts.xaml b/src/MaterialDesign3.Demo.Wpf/Alerts.xaml
new file mode 100644
index 0000000000..5944c8da4f
--- /dev/null
+++ b/src/MaterialDesign3.Demo.Wpf/Alerts.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesign3.Demo.Wpf/Alerts.xaml.cs b/src/MaterialDesign3.Demo.Wpf/Alerts.xaml.cs
new file mode 100644
index 0000000000..5345d446da
--- /dev/null
+++ b/src/MaterialDesign3.Demo.Wpf/Alerts.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesign3Demo;
+
+public partial class Alerts
+{
+ public Alerts() => InitializeComponent();
+}
diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
index 526947a680..a2511cc14f 100644
--- a/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
+++ b/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
@@ -291,6 +291,17 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
selectedIcon: PackIconKind.Card,
unselectedIcon: PackIconKind.CardOutline);
+ yield return new DemoItem(
+ "Alert",
+ typeof(Alerts),
+ [
+ DocumentationLink.DemoPageLink(),
+ DocumentationLink.StyleLink("Alert"),
+ DocumentationLink.ApiLink()
+ ],
+ selectedIcon: PackIconKind.AlertCircle,
+ unselectedIcon: PackIconKind.AlertCircleOutline);
+
yield return new DemoItem(
"Icon Pack",
typeof(IconPack),
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml
new file mode 100644
index 0000000000..d2dfca0722
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml.cs b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml.cs
new file mode 100644
index 0000000000..54e94ffbe3
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCloseExamples.xaml.cs
@@ -0,0 +1,15 @@
+namespace MaterialDesignDemo.Shared.Examples.Alerts;
+
+public partial class AlertCloseExamples : UserControl
+{
+ public AlertCloseExamples() => InitializeComponent();
+
+ private void Alert_OnCloseClick(object sender, RoutedEventArgs e)
+ => ((UIElement)sender).Visibility = Visibility.Hidden;
+
+ private void Reset_OnClick(object sender, RoutedEventArgs e)
+ {
+ InfoAlert.Visibility = Visibility.Visible;
+ WarningAlert.Visibility = Visibility.Visible;
+ }
+}
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml
new file mode 100644
index 0000000000..ced7748ed1
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml.cs b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml.cs
new file mode 100644
index 0000000000..6fc2a1adc0
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertCornerRadiusExamples.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesignDemo.Shared.Examples.Alerts;
+
+public partial class AlertCornerRadiusExamples : UserControl
+{
+ public AlertCornerRadiusExamples() => InitializeComponent();
+}
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml
new file mode 100644
index 0000000000..8205deb73a
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml.cs b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml.cs
new file mode 100644
index 0000000000..225b330bfa
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertElevationExamples.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesignDemo.Shared.Examples.Alerts;
+
+public partial class AlertElevationExamples : UserControl
+{
+ public AlertElevationExamples() => InitializeComponent();
+}
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml
new file mode 100644
index 0000000000..f419db3958
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml.cs b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml.cs
new file mode 100644
index 0000000000..2af0c13f58
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertExamples.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesignDemo.Shared.Examples.Alerts;
+
+public partial class AlertExamples : UserControl
+{
+ public AlertExamples() => InitializeComponent();
+}
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml
new file mode 100644
index 0000000000..658ec6ee7f
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml.cs b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml.cs
new file mode 100644
index 0000000000..ebcffe780f
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Examples/Alerts/AlertWithTitleExamples.xaml.cs
@@ -0,0 +1,6 @@
+namespace MaterialDesignDemo.Shared.Examples.Alerts;
+
+public partial class AlertWithTitleExamples : UserControl
+{
+ public AlertWithTitleExamples() => InitializeComponent();
+}
diff --git a/src/MaterialDesignThemes.Wpf/Alert.cs b/src/MaterialDesignThemes.Wpf/Alert.cs
new file mode 100644
index 0000000000..9e42e53679
--- /dev/null
+++ b/src/MaterialDesignThemes.Wpf/Alert.cs
@@ -0,0 +1,100 @@
+using System.ComponentModel;
+
+namespace MaterialDesignThemes.Wpf;
+
+///
+/// Displays a short message, tinted with the semantic color matching its .
+///
+[TemplatePart(Name = CloseButtonPartName, Type = typeof(ButtonBase))]
+public class Alert : ContentControl
+{
+ public const string CloseButtonPartName = "PART_CloseButton";
+
+ private ButtonBase? _closeButton;
+
+ static Alert()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(Alert), new FrameworkPropertyMetadata(typeof(Alert)));
+ }
+
+ public Severity Severity
+ {
+ get => (Severity)GetValue(SeverityProperty);
+ set => SetValue(SeverityProperty, value);
+ }
+
+ public static readonly DependencyProperty SeverityProperty =
+ DependencyProperty.Register(nameof(Severity), typeof(Severity), typeof(Alert), new PropertyMetadata(Severity.None));
+
+ public CornerRadius CornerRadius
+ {
+ get => (CornerRadius)GetValue(CornerRadiusProperty);
+ set => SetValue(CornerRadiusProperty, value);
+ }
+
+ public static readonly DependencyProperty CornerRadiusProperty =
+ DependencyProperty.Register(nameof(CornerRadius), typeof(CornerRadius), typeof(Alert), new PropertyMetadata(new CornerRadius(4)));
+
+ ///
+ /// Optional bold heading shown above the content. Null hides it.
+ ///
+ public object? Title
+ {
+ get => GetValue(TitleProperty);
+ set => SetValue(TitleProperty, value);
+ }
+
+ public static readonly DependencyProperty TitleProperty =
+ DependencyProperty.Register(nameof(Title), typeof(object), typeof(Alert), new PropertyMetadata(null));
+
+ ///
+ /// The icon shown before the content. Defaults to an icon matching ; null hides the icon.
+ ///
+ public PackIconKind? IconKind
+ {
+ get => (PackIconKind?)GetValue(IconKindProperty);
+ set => SetValue(IconKindProperty, value);
+ }
+
+ public static readonly DependencyProperty IconKindProperty =
+ DependencyProperty.Register(nameof(IconKind), typeof(PackIconKind?), typeof(Alert), new PropertyMetadata(null));
+
+ ///
+ /// Shows a close button; clicking it raises . Hiding the alert is up to the handler.
+ ///
+ public bool ShowCloseButton
+ {
+ get => (bool)GetValue(ShowCloseButtonProperty);
+ set => SetValue(ShowCloseButtonProperty, value);
+ }
+
+ public static readonly DependencyProperty ShowCloseButtonProperty =
+ DependencyProperty.Register(nameof(ShowCloseButton), typeof(bool), typeof(Alert), new PropertyMetadata(false));
+
+ [Category("Behavior")]
+ public event RoutedEventHandler CloseClick
+ {
+ add => AddHandler(CloseClickEvent, value);
+ remove => RemoveHandler(CloseClickEvent, value);
+ }
+
+ public static readonly RoutedEvent CloseClickEvent =
+ EventManager.RegisterRoutedEvent(nameof(CloseClick), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Alert));
+
+ public override void OnApplyTemplate()
+ {
+ _closeButton?.Click -= CloseButtonOnClick;
+
+ _closeButton = GetTemplateChild(CloseButtonPartName) as ButtonBase;
+
+ _closeButton?.Click += CloseButtonOnClick;
+
+ base.OnApplyTemplate();
+ }
+
+ private void CloseButtonOnClick(object sender, RoutedEventArgs e)
+ {
+ RaiseEvent(new RoutedEventArgs(CloseClickEvent, this));
+ e.Handled = true;
+ }
+}
diff --git a/src/MaterialDesignThemes.Wpf/Converters/SeverityToBrushConverter.cs b/src/MaterialDesignThemes.Wpf/Converters/SeverityToBrushConverter.cs
new file mode 100644
index 0000000000..0d6dc4acb9
--- /dev/null
+++ b/src/MaterialDesignThemes.Wpf/Converters/SeverityToBrushConverter.cs
@@ -0,0 +1,20 @@
+using System.Globalization;
+using System.Windows.Data;
+
+namespace MaterialDesignThemes.Wpf.Converters;
+
+///
+/// Converts a to its theme brush via .
+///
+public class SeverityToBrushConverter : IValueConverter
+{
+ public static readonly SeverityToBrushConverter Instance = new();
+
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ => value is Severity severity && SeverityBrushProvider.GetBrush(severity) is { } brush
+ ? brush
+ : DependencyProperty.UnsetValue;
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ => throw new NotImplementedException();
+}
diff --git a/src/MaterialDesignThemes.Wpf/SeverityBrushProvider.cs b/src/MaterialDesignThemes.Wpf/SeverityBrushProvider.cs
new file mode 100644
index 0000000000..8c01136719
--- /dev/null
+++ b/src/MaterialDesignThemes.Wpf/SeverityBrushProvider.cs
@@ -0,0 +1,37 @@
+using System.Windows.Media;
+
+namespace MaterialDesignThemes.Wpf;
+
+public enum Severity
+{
+ None,
+ Info,
+ Success,
+ Warning,
+ Error
+}
+
+///
+/// Maps a to its semantic theme brush.
+///
+public static class SeverityBrushProvider
+{
+ ///
+ /// The theme resource key of the brush for ; null for .
+ ///
+ public static string? GetResourceKey(Severity severity) => severity switch
+ {
+ Severity.Info => "MaterialDesign.Brush.Info",
+ Severity.Success => "MaterialDesign.Brush.Success",
+ Severity.Warning => "MaterialDesign.Brush.Warning",
+ Severity.Error => "MaterialDesign.Brush.Error",
+ _ => null
+ };
+
+ ///
+ /// The current application theme's brush for ; null for or when not found.
+ /// The theme brushes are replaced on theme change, so look it up again (or use a DynamicResource with ) instead of caching it.
+ ///
+ public static SolidColorBrush? GetBrush(Severity severity)
+ => GetResourceKey(severity) is { } key ? Application.Current?.TryFindResource(key) as SolidColorBrush : null;
+}
diff --git a/src/MaterialDesignThemes.Wpf/Themes/Generic.xaml b/src/MaterialDesignThemes.Wpf/Themes/Generic.xaml
index de444e303c..741220304f 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/Generic.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/Generic.xaml
@@ -16,6 +16,7 @@
MaterialDesignTheme.Defaults.xaml
in your App.xaml
-->
+
@@ -35,6 +36,7 @@
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Alert.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Alert.xaml
new file mode 100644
index 0000000000..4030ce1125
--- /dev/null
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Alert.xaml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Alerts/AlertTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Alerts/AlertTests.cs
new file mode 100644
index 0000000000..c5a2a5eaa4
--- /dev/null
+++ b/tests/MaterialDesignThemes.UITests/WPF/Alerts/AlertTests.cs
@@ -0,0 +1,122 @@
+using System.Windows.Media;
+using System.Windows.Documents;
+
+namespace MaterialDesignThemes.UITests.WPF.Alerts;
+
+public class AlertTests : TestBase
+{
+ [Test]
+ [DoesNotRequireInteraction]
+ [Arguments(Severity.Info, "MaterialDesign.Brush.Info", PackIconKind.InformationOutline)]
+ [Arguments(Severity.Success, "MaterialDesign.Brush.Success", PackIconKind.CheckCircleOutline)]
+ [Arguments(Severity.Warning, "MaterialDesign.Brush.Warning", PackIconKind.AlertOutline)]
+ [Arguments(Severity.Error, "MaterialDesign.Brush.Error", PackIconKind.AlertCircleOutline)]
+ public async Task WithSeverity_UsesSemanticColorAndIcon(Severity severity, string expectedBrushName, PackIconKind expectedIcon)
+ {
+ IVisualElement alert = await LoadXaml($"""""");
+ Color semanticColor = await GetThemeColor(expectedBrushName);
+ IVisualElement tint = await alert.GetElement("Tint");
+ IVisualElement icon = await alert.GetElement("Icon");
+
+ await Assert.That(await alert.GetForegroundColor()).IsEqualTo(semanticColor);
+ await Assert.That(await tint.GetVisibility()).IsEqualTo(Visibility.Visible);
+ await Assert.That(await tint.GetBackgroundColor()).IsEqualTo(semanticColor);
+ await Assert.That(await icon.GetVisibility()).IsEqualTo(Visibility.Visible);
+ await Assert.That(await icon.GetProperty(nameof(Wpf.PackIcon.Kind))).IsEqualTo(expectedIcon);
+ }
+
+ [Test]
+ [DoesNotRequireInteraction]
+ public async Task SeverityNone_HasNoTintAndUsesDefaultForeground()
+ {
+ IVisualElement alert = await LoadXaml("""""");
+ Color foreground = await GetThemeColor("MaterialDesign.Brush.Foreground");
+ IVisualElement tint = await alert.GetElement("Tint");
+ IVisualElement icon = await alert.GetElement("Icon");
+
+ await Assert.That(await alert.GetForegroundColor()).IsEqualTo(foreground);
+ await Assert.That(await tint.GetVisibility()).IsEqualTo(Visibility.Collapsed);
+ await Assert.That(await icon.GetProperty(nameof(Wpf.PackIcon.Kind))).IsEqualTo(PackIconKind.NoteTextOutline);
+ }
+
+ [Test]
+ [DoesNotRequireInteraction]
+ public async Task ExplicitIconKind_OverridesSeverityIcon()
+ {
+ IVisualElement alert = await LoadXaml("""""");
+ IVisualElement icon = await alert.GetElement("Icon");
+
+ await Assert.That(await icon.GetProperty(nameof(Wpf.PackIcon.Kind))).IsEqualTo(PackIconKind.Bell);
+ }
+
+ [Test]
+ [DoesNotRequireInteraction]
+ public async Task NullIconKind_HidesIcon()
+ {
+ IVisualElement alert = await LoadXaml("""""");
+ IVisualElement icon = await alert.GetElement("Icon");
+
+ await Assert.That(await icon.GetVisibility()).IsEqualTo(Visibility.Collapsed);
+ }
+
+ [Test]
+ [DoesNotRequireInteraction]
+ [Arguments(null, Visibility.Collapsed)]
+ [Arguments("Some title", Visibility.Visible)]
+ public async Task Title_ControlsTitleVisibility(string? title, Visibility expectedVisibility)
+ {
+ string titleAttribute = title is null ? "" : $"""Title="{title}" """;
+ IVisualElement alert = await LoadXaml($"""""");
+ IVisualElement titlePresenter = await alert.GetElement("Title");
+
+ await Assert.That(await titlePresenter.GetVisibility()).IsEqualTo(expectedVisibility);
+ }
+
+ [Test]
+ [DoesNotRequireInteraction]
+ [Arguments(false, Visibility.Collapsed)]
+ [Arguments(true, Visibility.Visible)]
+ public async Task ShowCloseButton_ControlsCloseButtonVisibility(bool showCloseButton, Visibility expectedVisibility)
+ {
+ IVisualElement alert = await LoadXaml($"""""");
+ IVisualElement