0

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>
            <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>
            <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"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by nmaillet
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.