I have a Storyboard which targets an Ellipse. How do I make the Storyboard target an image which I have in a List<>?

This is the code:

<Storyboard x:Name="sbMoveImages">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0" Value="-1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:3" Value="641"/>
                <EasingDoubleKeyFrame KeyTime="0:0:5" Value="640"/>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:3" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:5" Value="160"/>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0:0:3" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:5" Value="359.82"/>

First, I'm a Windows developer, not a mobile developer. So your mileage may vary.

Use the Storyboard.Target attached property instead. Is the image you are referencing going to change? Or the index you are referencing within the list? You can reference lists in XAML (they must be exposed as a property, not a field) in the bindings path with something like this:

<DoubleAnimationUsingKeyFrames Storyboard.Target="{Binding MyListProperty[0], ElementName=myWindow}" ...>

If the image is going to change, you'll have to use an ObservableCollection<> or something that correctly implements the INotifyCollectionChanged interface. If the index you will be referencing will be changing, I would instead recommend updating a custom DependencyProperty when necessary.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.