StoryBoard is not working
-
If I add scale.BeginAnimation(ScaleTransform.ScaleXProperty, growAnimation); then animation works fine, but I need to add timeline, so StortBoard should work. Now I added almost same code Now it is not working. Am I am setting the wrong Property, but I shouldn't because it is same property. Storyboard.SetTarget(growAnimation, myCanvas); Storyboard.SetTargetProperty(growAnimation, new PropertyPath(ScaleTransform.ScaleXProperty)); sb.Children.Add(growAnimation); sb.Begin(); Any help will be very much appriciated. Agha Khan private void Animate() { Image finalImage = new Image(); BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri("pack://application:,,,/Billboard;component/Images/Crystal.jpg"); logo.EndInit(); finalImage.Source = logo; Canvas myCanvas = new Canvas(); myCanvas.Width = 660; myCanvas.Height = 475; myCanvas.Background = new ImageBrush(finalImage.Source); this.ImageGrid.Children.Add(myCanvas); Storyboard sb = new Storyboard(); ScaleTransform scale = new ScaleTransform(1.0, 1.0, 33, 0); myCanvas.RenderTransformOrigin = new Point(0, 0); myCanvas.RenderTransform = scale; DoubleAnimation growAnimation = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(2)); growAnimation.BeginTime = TimeSpan.FromSeconds(0); // Apply the animation to the Canvas's Width property. // myCanvas.BeginAnimation(Canvas.WidthProperty, growAnimation); // scale.BeginAnimation(ScaleTransform.ScaleXProperty, growAnimation); Storyboard.SetTarget(growAnimation, myCanvas); Storyboard.SetTargetProperty(growAnimation, new PropertyPath(ScaleTransform.ScaleXProperty)); // Looks like bug is in above line, but unable to find it. sb.Children.Add(growAnimation); sb.Begin(); }