问题描述
您好我想在Windows手机中创建动画我可以通过Expression混合创建动画但我想通过c#代码创建动画但我已经尝试了很多但它不在这里工作我想从右端移动矩形左边只有x坐标,但它正在发出错误请帮帮我 Hi i want to create animation in windows phone i can able to create animation through Expression blend but i want to create animation through c# code but i have tried a lot but its not working here i want to move a rectange from right end to left end only in x coordinate but it was rasing an error please help me 这篇关于通过c#windows phone创建动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
矩形r = new Rectangle();
r.Fill = new SolidColorBrush(Colors.Purple);
r.Width = 100 ;
r.Height = 100 ;
r.Name = rectange;
LayoutRoot.Children.Add(r);
Storyboard sb = new Storyboard();
DoubleAnimation fadeInAnimation = new DoubleAnimation();
fadeInAnimation.From = 340 ;
fadeInAnimation.To = 0 ;
fadeInAnimation.Duration = new 持续时间(TimeSpan.FromSeconds( 1 。 0 跨度>));
Storyboard.SetTarget(fadeInAnimation,r);
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath( (UIElement.RenderTransform)(CompositeTransform.TranslateX)。跨度>));
sb.Children.Add(fadeInAnimation);
sb.Begin();
它在sb.begin()中引发错误;
Rectangle r = new Rectangle();
r.Fill = new SolidColorBrush(Colors.Purple);
r.Width = 100;
r.Height = 100;
r.Name = "rectange";
LayoutRoot.Children.Add(r);
Storyboard sb = new Storyboard();
DoubleAnimation fadeInAnimation = new DoubleAnimation();
fadeInAnimation.From = 340;
fadeInAnimation.To = 0;
fadeInAnimation.Duration = new Duration(TimeSpan.FromSeconds(1.0));
Storyboard.SetTarget(fadeInAnimation, r);
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
sb.Children.Add(fadeInAnimation);
sb.Begin();
it was raising error at sb.begin();