예제 #1
0
        public void CreateAnimationHead()
        {
            // VisualTreeHelper.GetOffset
            var target = Head;
            //var top = VisualTreeHelper.GetOffset(target);
            //var left = VisualTreeHelper.GetOffset(target);
            //TranslateTransform trans = new TranslateTransform();
            //Head.RenderTransform = trans;
            //DoubleAnimation anim1 = new DoubleAnimation(3,10, TimeSpan.FromSeconds(10));
            //DoubleAnimation anim2 = new DoubleAnimation(3, 10, TimeSpan.FromSeconds(10));
            //Head.BeginAnimation(TranslateTransform.XProperty, anim1);
            //Head.BeginAnimation(TranslateTransform.YProperty, anim2);

            DoubleAnimation myDoubleAnimation = new DoubleAnimation();

            myDoubleAnimation.From = -550;
            myDoubleAnimation.To   = 0.0;

            myDoubleAnimation.Duration       = new Duration(TimeSpan.FromSeconds(2));
            myDoubleAnimation.AutoReverse    = true;
            myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //  myStoryboard = new Storyboard();
            // myStoryboard.Children.Add(myDoubleAnimation);

            Head.BeginAnimation(TranslateTransform.XProperty, myDoubleAnimation);
        }