/// <summary> /// Wird aufgerufen wenn sich der Inhalt des Controls ändert. /// </summary> /// <param name="oldContent"></param> /// <param name="newContent"></param> protected override void OnContentChanged(object oldContent, object newContent) { if (_paintArea != null && _mainContent != null) { _paintArea.Fill = AnimateLib.CreateBrushFromVisual(_mainContent, (int)this.ActualWidth, (int)this.ActualHeight); _BeginAnimateContentReplacement(); } base.OnContentChanged(oldContent, newContent); }
protected override void OnContentChanged(object oldContent, object newContent) { if (_displayTop != null && _displayBottom != null && _rectangleTop != null && _rectangleBottom != null) { _rectangleTop.Fill = AnimateLib.CreateBrushFromVisual(_displayTop, (int)_rectangleTop.ActualWidth, (int)_rectangleTop.ActualHeight); _rectangleBottomStatic.Fill = AnimateLib.CreateBrushFromVisual(_displayBottom, (int)_rectangleBottomStatic.ActualWidth, (int)_rectangleBottomStatic.ActualHeight); _BeginAnimateContentReplacement(); } base.OnContentChanged(oldContent, newContent); }
private void _BeginAnimateContentReplacement() { var flapTransformTop = new ScaleTransform { CenterY = _rectangleTop.ActualHeight / 2 }; _rectangleTop.RenderTransform = flapTransformTop; var flapTransformBottom = new ScaleTransform { CenterY = _rectangleBottom.ActualHeight / 2 }; _rectangleBottom.RenderTransform = flapTransformBottom; _rectangleTop.Visibility = Visibility.Visible; _rectangleBottom.Visibility = Visibility.Visible; _rectangleBottomStatic.Visibility = Visibility.Visible; IEasingFunction ease = null;//new BackEase() { EasingMode = EasingMode.EaseOut }; AnimationTimeline animationTop = AnimateLib.CreateAnimation(1, 0, 0, 0.1, null, (object s, EventArgs e) => { _rectangleTop.Visibility = Visibility.Hidden; _rectangleBottom.Visibility = Visibility.Visible; _rectangleBottom.Fill = AnimateLib.CreateBrushFromVisual(_displayBottom, (int)_rectangleBottom.ActualWidth, (int)_rectangleBottom.ActualHeight); }); AnimationTimeline animationBottom = AnimateLib.CreateAnimation(0, 1, 0.1, 0.1, ease, (object s, EventArgs e) => { _rectangleBottom.Visibility = Visibility.Hidden; _rectangleBottomStatic.Visibility = Visibility.Hidden; }); flapTransformTop.BeginAnimation(ScaleTransform.ScaleYProperty, animationTop, HandoffBehavior.SnapshotAndReplace); flapTransformBottom.BeginAnimation(ScaleTransform.ScaleYProperty, animationBottom, HandoffBehavior.SnapshotAndReplace); }