views:

222

answers:

0

Hi Everyone,

Having a problem trying to get a Scale transform working using dynamically created animations

here is the code

        Storyboard story = (Storyboard)Resources["Zoom"];
        //Add the slides to the stackpanel
        foreach (UIElement element in _slideList)
        {
            //Apply the zoom story
            FrameworkElement clone = (FrameworkElement) XamlProcessor.CloneElement(element);
            clone.LayoutTransform = new ScaleTransform(0.5, 0.5);

            ScaleTransform transform = (ScaleTransform)clone.LayoutTransform;
            DoubleAnimation animationX = new DoubleAnimation(1, 0.1, new Duration(new TimeSpan(0, 0, 2)), FillBehavior.HoldEnd);
            DoubleAnimation animationY = new DoubleAnimation(1, 0.1, new Duration(new TimeSpan(0, 0, 2)), FillBehavior.HoldEnd);

            story.Children.Add(animationX);
            Storyboard.SetTarget(animationX, transform);
            Storyboard.SetTargetProperty(animationX, new PropertyPath(ScaleTransform.ScaleXProperty));

            story.Children.Add(animationY);
            Storyboard.SetTarget(animationY, transform);
            Storyboard.SetTargetProperty(animationY, new PropertyPath(ScaleTransform.ScaleYProperty));
            stackPanelMap.Children.Add(clone);

        }
        story.Completed += new EventHandler(story_Completed);
        story.Begin();

The story runs fine but the scale isnt changed, im sure im missing something silly!! thanks in advance