问题
I have a story board with double animation,
<Storyboard x:Name="Storyboard1">
<DoubleAnimation From="0" To="200" Duration="0:0:2" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
</DoubleAnimation>
</Storyboard>
and I just adding TargetNameProperty dynamically,
private void set_animation_for_images(string target_name)
{
Storyboard1.Stop();
Storyboard1.SetValue(Storyboard.TargetNameProperty, target_name);
Storyboard1.Begin();
}
Here is it possible to call this set_animation_for_images() method continuously for different image at same starting time?
回答1:
Because you only have the one storyboard, you can only have it targeting one element at a time. To target multiple images at a time, you may need to generate the whole thing in code:
private void animateImage(string target)
{
Storyboard testStoryboard = new Storyboard();
...
testStoryboard.SetValue(Storyboard.TargetNameProperty, target_name);
testStoryboard.Begin();
}
If all the images are in a container, you could always target the container itself, but that might not get the effect you want.
来源:https://stackoverflow.com/questions/24738976/is-it-possible-to-start-same-animation-for-different-controls-at-same-start-time