My Code is posted Below. I am creating an image, and attempting to add animation to it. I am sure it was working at one point, I made a small change, it failed I undid the change (literally undo) and now it continues to fail. I am attempting to make an image change ever half second to another image, then change back after another half second.
<Image Height="30" HorizontalAlignment="Left" Margin="198,90,0,0" Name="OldMan" Stretch="Fill" VerticalAlignment="Top" Width="30" Source="/TestingWpF;component/Images/Old1.png" >
<Image.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard >
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="OldMan" Storyboard.TargetProperty="(Image.Source)" RepeatBehavior="Forever">
<DiscreteObjectKeyFrame KeyTime="00:00:00.5000000">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="/TestingWpF;component/Images/Old1.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="00:00:01.0000000">
<DiscreteObjectKeyFrame.Value>
<BitmapImage UriSource="/TestingWpF;component/Images/Old2.png" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
The problem is that you don’t have your duration set. You’ll just get the first keyframe, but not the next. Try adding something like
Duration="00:00:01.5"toObjectAnimationUsingKeyFrames