Forum Cross Platform with Xamarin

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Not playing animation in Storyboard (using ObjectAnimationUsingKeyFrames) in WindowsPhone 7

Hiton4ikHiton4ik UAMember
edited November 2012 in Cross Platform with Xamarin

I can not play animation storyboard. Displayed only last picture animation. What could be wrong?

My code create animation:

public static class AnimationHelper
    {
        private const string PathImageAnimation = "/LeSommet.ZooSnap.UI.WindowsPhone;component/Resources/Images/Animation/ButtonState{0}.png";

        public static void StartAnimation(UIElement target)
        {
            Storyboard storyboard = new Storyboard();

            ObjectAnimationUsingKeyFrames objectAnimation = new ObjectAnimationUsingKeyFrames();
            objectAnimation.AutoReverse = false;
            objectAnimation.SpeedRatio = 2;
            Storyboard.SetTargetProperty(objectAnimation, new PropertyPath("Source"));
            Storyboard.SetTarget(objectAnimation, target);

            for (int i = 1; i <= 4; i++)
            {
                DiscreteObjectKeyFrame discreteObject = new DiscreteObjectKeyFrame()
                {
                    KeyTime = TimeSpan.FromMilliseconds(1000),
                    Value = new BitmapImage(new Uri(string.Format(PathImageAnimation, i), UriKind.Relative))
                };
                objectAnimation.KeyFrames.Add(discreteObject);
            }
            storyboard.Children.Add(objectAnimation);


            storyboard.Begin();
        }
    }

My code Image xaml:

<Image Source="/LeSommet.ZooSnap.UI.WindowsPhone;component/Resources/Images/Animation/ButtonState5.png"                            
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Width="110" Height="110" Stretch="Fill"
                           x:Name="imageSquareAnimation">

Posts

  • StuartLodgeStuartLodge USBeta ✭✭✭

    Answered on SO - this question doesn't really belong on Xam forums.

    Also please only email me your questions if they are about MvvmCross or another of my OSS projects - I've already got plenty of questions to answer - thanks :)

This discussion has been closed.