how to swap positions of 2 grids in an animation on windows phone using storyboard
I am trying to swap the positions of 2 grids along the x axis in an animation using a storyboard on windows phone. So far I have the following code which results in the grids moving but not to the either ones original position.
double ScreenWidth = Application.Current.Host.Content.ActualWidth; double ScreenHeight = Application.Current.Host.Content.ActualHeight; Storyboard swapStory = new Storyboard(); var firstGridTransform = firstGrid.TransformToVisual(Application.Current.RootVisual).Transform(new Point(0, 0)); var secondGridTransform = secondGrid.TransformToVisual(Application.Current.RootVisual).Transform(new Point(0, 0)); DoubleAnimation firstAnim = new DoubleAnimation(); firstAnim.Duration = TimeSpan.FromMilliseconds(animTime); firstAnim.To = secondGridTransform.X; firstAnim.From = firstGridTransform.X; Storyboard.SetTarget(firstAnim, firstGrid); Storyboard.SetTargetProperty(firstAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); swapStory.Children.Add(firstAnim); DoubleAnimation secondAnim = new DoubleAnimation(); secondAnim.Duration = TimeSpan.FromMilliseconds(animTime); secondAnim.To = firstGridTransform.X; secondAnim.From = secondGridTransform.X; Storyboard.SetTarget(secondAnim, secondGrid); Storyboard.SetTargetProperty(secondAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); swapStory.Children.Add(secondAnim); swapStory.Begin();
Answers & Comments...
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog