动态切换ImageSource

动态切换ImageSource

Silverlight StoryBoard 动态切换ImageSource

<StackPanel Grid.Row="1" Orientation="Horizontal">

                            <Image x:Name="Mouth"  Style="{StaticResource ModuleImageStyle}" Source="../Assets/icons/large/1389966495_Messages.png">
<Image.Triggers>
<EventTrigger RoutedEvent="StackPanel.Loaded">
<BeginStoryboard>
<Storyboard x:Name="SingingAnim" AutoReverse="True" RepeatBehavior="Forever">
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Mouth" Storyboard.TargetProperty="(Image.Source)"> <DiscreteObjectKeyFrame KeyTime="00:00:01">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="../Assets/icons/large/1389966495_Messages.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="00:00:02">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="../Assets/icons/large/1389966508_Analytics_one.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="00:00:03">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="../Assets/icons/large/1389966546_Notes.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="00:00:04">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="../Assets/icons/large/1389966549_Analytics_two.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="00:00:05">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="../Assets/icons/large/1389966553_Analytics.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image> <Rectangle RadiusX="60" RadiusY="60"
x:Name="MyAnimatedRectangle"
Width="100"
Height="100"
Fill="LightSeaGreen">
<Rectangle.Triggers> <!-- Animates the rectangle's opacity. -->
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyAnimatedRectangle"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle> </StackPanel>
05-11 16:04