private static void NotificationLevelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NotificationLevel level = (NotificationLevel)e.NewValue; ToastNotificationWindow instance = d as ToastNotificationWindow; Brush brush = null; switch (level) { case NotificationLevel.Information: brush = (Brush)instance.FindResource("HighlightDarkBrush"); instance.btnLevel.IconKey = "appbar_information"; break; case NotificationLevel.Warning: brush = (Brush)instance.FindResource("AlertTextBrush"); instance.btnLevel.IconKey = "appbar_warning"; instance.btnLevel.Visibility = Visibility.Visible; break; case NotificationLevel.Error: brush = (Brush)instance.FindResource("BadTextBrush"); instance.btnLevel.IconKey = "appbar_warning_circle"; instance.btnLevel.Visibility = Visibility.Visible; break; case NotificationLevel.Good: brush = (Brush)instance.FindResource("GoodTextBrush"); instance.btnLevel.IconKey = "appbar_check"; instance.btnLevel.Visibility = Visibility.Visible; break; } instance.mainBorder.BorderBrush = brush; instance.iconBorder.Background = brush; }
/// <summary> /// Shows the toast notification. /// </summary> /// <param name="content">The content of the toast notification message.</param> /// <param name="level">The notification level.</param> /// <param name="callbackAction">This action will be called if the user clicked on the Toast Notification.</param> /// <param name="timeout">The timeout in second when the notification hides itself, default value is 0</param> /// <remarks> /// If multiple toast notification is shown, they will shown one under another. /// </remarks> public void ShowToastNotification(string content, NotificationLevel level, Action callbackAction = null, int timeout = 5) { ToastNotificationWindow window = new ToastNotificationWindow(this, content, level, callbackAction, timeout); window.Show(); }