/// <summary> /// Manager on message dismissed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="NotificationMessageManagerEventArgs"/> instance containing the event data.</param> /// <exception cref="InvalidOperationException">Can't use both ItemsSource and Items collection at the same time.</exception> private void ManagerOnOnMessageDismissed(object sender, NotificationMessageManagerEventArgs args) { if (this.ItemsSource != null) { throw new InvalidOperationException( "Can't use both ItemsSource and Items collection at the same time."); } if (args.Message is INotificationAnimation) { var animatableMessage = args.Message as INotificationAnimation; var animation = animatableMessage.AnimationOut; if (animatableMessage.Animates && animatableMessage.AnimatableElement != null && animation != null && animatableMessage.AnimationOutDependencyProperty != null) { animation.Completed += (s, a) => this.RemoveMessage(args.Message); animatableMessage.AnimatableElement.BeginAnimation(animatableMessage.AnimationOutDependencyProperty, animation); } else { this.RemoveMessage(args.Message); } } else { this.RemoveMessage(args.Message); } }
/// <summary> /// Manager on message queued. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="NotificationMessageManagerEventArgs"/> instance containing the event data.</param> /// <exception cref="InvalidOperationException">Can't use both ItemsSource and Items collection at the same time.</exception> private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerEventArgs args) { if (this.ItemsSource != null) { throw new InvalidOperationException( "Can't use both ItemsSource and Items collection at the same time."); } this.Items?.Add(args.Message); }
/// <summary> /// Manager on message queued. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="NotificationMessageManagerEventArgs"/> instance containing the event data.</param> /// <exception cref="InvalidOperationException">Can't use both ItemsSource and Items collection at the same time.</exception> private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerEventArgs args) { if (this.ItemsSource != null) { throw new InvalidOperationException( "Can't use both ItemsSource and Items collection at the same time."); } this.Items?.Add(args.Message); if (args.Message is INotificationAnimation) { var animatableMessage = args.Message as INotificationAnimation; var animation = animatableMessage.AnimationIn; if (animatableMessage.Animates && animatableMessage.AnimatableElement != null && animation != null && animatableMessage.AnimationInDependencyProperty != null) { animatableMessage.AnimatableElement.BeginAnimation(animatableMessage.AnimationInDependencyProperty, animation); } } }