图像动画wpf

时间:2010-07-01 04:55:33

标签: wpf image animation

我想像幻灯片一样逐个移动图像。我使用以下代码移动一个图像。如何将此动画应用于图像文件夹中的所有图像。

代码:

 <Image Name="img" Width="50" Height="25"  Grid.Row="3" HorizontalAlignment="Left" Source="btn_audio_stop.jpg">
        <Image.Triggers>
            <EventTrigger RoutedEvent="Image.Loaded">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Trans" Storyboard.TargetProperty="Y" Duration="0:0:25">
                                <LinearDoubleKeyFrame Value="350" KeyTime="0:0:25" />
                                <!--<LinearDoubleKeyFrame Value="50" KeyTime="0:0:5" />
                                <LinearDoubleKeyFrame Value="200" KeyTime="0:0:3" />-->
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
        </Image.Triggers>
        <Image.RenderTransform>
            <TranslateTransform x:Name="Trans" X="0" Y="0" />
        </Image.RenderTransform>
    </Image>