private void ShowAnimatedOverlay() { if (OverlayGrid is null) { throw new InvalidOperationException("Cannot find overlay in Associated object"); } if (OverlayGrid.Visibility == Visibility.Visible && _overlayStoryboard is null) { return; } if (ActiveContentContainer.Visibility == Visibility.Hidden) { ActiveContentContainer.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible); } Dispatcher.VerifyAccess(); var storyboard = AnimationService.GetFadeInAnimation(OverlayGrid); _overlayStoryboard = storyboard; if (TryGetOverlayFadingStoryboardAnimation(storyboard, out var animation)) { OverlayGrid.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible); animation.SetCurrentValue(DoubleAnimation.ToProperty, (double?)0.7); EventHandler completionHandler = null; completionHandler = (sender, args) => { storyboard.Completed -= completionHandler; if (_overlayStoryboard == storyboard) { _overlayStoryboard = null; } }; storyboard.Completed += completionHandler; OverlayGrid.BeginStoryboard(storyboard); } else { ShowOverlay(); } }
private void HideActiveContainer() { ActiveContentContainer.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Hidden); }