diff --git a/src/Local/Project1.UI/Controls/Project1UIWindow.cs b/src/Local/Project1.UI/Controls/Project1UIWindow.cs index 92288ec..f01cb85 100644 --- a/src/Local/Project1.UI/Controls/Project1UIWindow.cs +++ b/src/Local/Project1.UI/Controls/Project1UIWindow.cs @@ -207,6 +207,10 @@ public Project1UIWindow() //HandleAnimationSetting(); Loaded += new RoutedEventHandler(window_Loaded); + + //动画 + var transformGroup = new TransformGroup(); + RenderTransform = transformGroup; } ///// @@ -321,16 +325,17 @@ public void CloseNavigationView() private void CreateWindowOpenAnimation() { + Opacity = 0; openWindowStoryboard = new Storyboard(); var duration = TimeSpan.FromSeconds(1); - var transformGroup = new TransformGroup(); - this.RenderTransform = transformGroup; + var translateTF = new TranslateTransform() { X = 0, Y = 0 }; + var scaleTF = new ScaleTransform() { CenterX = ActualWidth, @@ -338,8 +343,9 @@ private void CreateWindowOpenAnimation() ScaleX = 0, ScaleY = 0 }; - transformGroup.Children.Add(translateTF); - transformGroup.Children.Add(scaleTF); + + (RenderTransform as TransformGroup).Children.Add(translateTF); + (RenderTransform as TransformGroup).Children.Add(scaleTF); @@ -393,25 +399,22 @@ private void CreateWindowCloseAnimation() { closeWindowStoryboard = new Storyboard(); var duration = TimeSpan.FromSeconds(1); - if (RenderTransform == null) + + var translateTF = new TranslateTransform() { - var transformGroup = new TransformGroup(); - RenderTransform = transformGroup; - var translateTF = new TranslateTransform() - { - X = 0, - Y = 0 - }; - var scaleTF = new ScaleTransform() - { - CenterX = ActualWidth / 2, - CenterY = ActualHeight / 2, - ScaleX = 0, - ScaleY = 0 - }; - transformGroup.Children.Add(translateTF); - transformGroup.Children.Add(scaleTF); - } + X = 0, + Y = 0 + }; + var scaleTF = new ScaleTransform() + { + CenterX = ActualWidth / 2, + CenterY = ActualHeight / 2, + ScaleX = 0, + ScaleY = 0 + }; + (RenderTransform as TransformGroup).Children.Add(translateTF); + (RenderTransform as TransformGroup).Children.Add(scaleTF); + //位移动画 @@ -573,7 +576,7 @@ private void AnimationHide(CompletedActionType completedAction) { if (IsAnimation) { - if (RenderTransform == null) + if ((RenderTransform as TransformGroup).Children.Count == 0) { CreateWindowOpenAnimation(); CreateWindowCloseAnimation(); @@ -595,9 +598,9 @@ private void AnimationHide(CompletedActionType completedAction) } else { - if (RenderTransform != null) + if ((RenderTransform as TransformGroup).Children.Count != 0) { - RenderTransform = null; + (RenderTransform as TransformGroup).Children.Clear(); } Opacity = 0; CompletedAction(completedAction); @@ -613,7 +616,7 @@ private void AnimationShow(CompletedActionType completedAction) { if (IsAnimation) { - if (RenderTransform == null) + if ((RenderTransform as TransformGroup).Children.Count == 0) { CreateWindowOpenAnimation(); CreateWindowCloseAnimation(); @@ -629,9 +632,9 @@ private void AnimationShow(CompletedActionType completedAction) } else { - if (RenderTransform != null) + if ((RenderTransform as TransformGroup).Children.Count != 0) { - RenderTransform = null; + (RenderTransform as TransformGroup).Children.Clear(); } Opacity = 1; CompletedAction(completedAction);