I am trying to set a storyboard in code behind, but an exception is thrown every time saying
"Cannot resolve TargetProperty (UIElement.RenderTransform).(CompositeTransform.ScaleX) on specified object."
Here is my code:
Image img = new Image() { Source = image.Source, Name="image"+i.ToString()};
var pointedStoryboard = new Storyboard();
var doubleAnnimationX = new DoubleAnimation();
doubleAnnimationX.Duration = TimeSpan.FromMilliseconds(500);
doubleAnnimationX.To = 2;
pointedStoryboard.Children.Add(doubleAnnimationX);
Storyboard.SetTarget(doubleAnnimationX, img);
Storyboard.SetTargetProperty(doubleAnnimationX, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
I tried also
Storyboard.SetTargetName(doubleAnnimationX, "image" + i.ToString());
instead of
Storyboard.SetTarget(doubleAnnimationX, img);
but it did work too , don't know exactly what to do , I would be so thankful if you help me !
thanks in advance .
Best Answer
You need to add a composite transform to your image first.
Then you should be able to reference it.