winrt 页面进入动画_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > winrt 页面进入动画

winrt 页面进入动画

 2014/6/9 17:32:13  wangjinming  程序员俱乐部  我要评论(0)
  • 摘要:privateasyncvoidDoAnimistion(){Storyboardstoryboard=newStoryboard();using(IEnumerator<DependencyObject>enumerator=stack.Children.ToList().GetEnumerator())//此处的stack是一个StackPanel,我要对它的子元素做动画{Randomrandom=newRandom();TimeSpantime=TimeSpan
  • 标签:
private async void DoAnimistion()
{
Storyboard storyboard = new Storyboard(); using (IEnumerator<DependencyObject> enumerator = stack.Children.ToList().GetEnumerator())       //此处的stack是一个StackPanel,我要对它的子元素做动画
{ Random random
= new Random(); TimeSpan time = TimeSpan.FromSeconds(0.0); var ts = TimeSpan.FromMilliseconds(80.0); double angle = -120.0; while (enumerator.MoveNext()) { //double num = random.Next(200, 500); FrameworkElement frameworkElement = (FrameworkElement)enumerator.Current; DoubleAnimationUsingKeyFrames xdoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); xdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), 380)); xdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(xdoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(xdoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(xdoubleAnimationUsingKeyFrames, TargetProperty.RenderTransformTranslateX); storyboard.Children.Add(xdoubleAnimationUsingKeyFrames); DoubleAnimationUsingKeyFrames ydoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); ydoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), angle)); ydoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(ydoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(ydoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(ydoubleAnimationUsingKeyFrames, TargetProperty.ProjectionRotationY); storyboard.Children.Add(ydoubleAnimationUsingKeyFrames); var num3 = -1.0 * (Math.Tan(DegreesToRadians(angle)) * frameworkElement.ActualWidth); num3 += frameworkElement.ActualWidth; DoubleAnimationUsingKeyFrames zdoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); zdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), num3)); zdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(zdoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(zdoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(zdoubleAnimationUsingKeyFrames, TargetProperty.ProjectionGlobalOffsetZ); storyboard.Children.Add(zdoubleAnimationUsingKeyFrames); time = time.Add(ts); } } storyboard.Begin();
}
public static double DegreesToRadians(double degrees)
        {
            return degrees * 2.0 * 3.1415926535897931 / 360.0;
        }

 

  • 相关文章
发表评论
用户名: 匿名