private void NotifyUser(string message) { if (!userNotificationTimer.IsEnabled) { DoubleAnimation da = new DoubleAnimation { From = 0, To = 1, Duration = new Duration(TimeSpan.FromSeconds(0.55)), AutoReverse = false }; UserNotificationMessage.Text = message; UserNotificationMessage.BeginAnimation(OpacityProperty, da); userNotificationTimer.Tick += NotificationMessageTimeout; userNotificationTimer.Start(); } else { userNotificationTimer.Stop(); UserNotificationMessage.Text = message; userNotificationTimer.Tick += NotificationMessageTimeout; userNotificationTimer.Start(); } }
private void NotificationMessageTimeout(object sender, EventArgs e) { DoubleAnimation da = new DoubleAnimation { From = 1, To = 0, Duration = new Duration(TimeSpan.FromSeconds(0.55)), AutoReverse = false }; da.Completed += RemoveTextInNotification; UserNotificationMessage.BeginAnimation(OpacityProperty, da); (sender as DispatcherTimer).Stop(); }