2012-01-23 52 views
1

在我的earlier问题中,我问如何播放媒体元素中的透明AVI文件。我被建议让透明的PNG文件顺序加载,以便它看起来像一个动画。使用XAML动画作为动画加载不同的图像?

我这样做达到的:

我有60个PNG图像投2秒的动画。使用DispatcherTimer类我每天333333个蜱(1,00,00,000 * 2/60蜱)后改变图像源

*注:1,00,00,000是蜱在第二

我要的号码在XAML中做这个动画?这个怎么做?

回答

0

你是什么意思“作为双动画”?

在纯XAML中实现此功能将会非常冗长,因为每个PNG图像都必须声明为资源并在故事板中显式加载。例如:

<BeginStoryboard> 
    <Storyboard> 
     <ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="MyButton" Storyboard.TargetProperty="Content"> 
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding Source={StaticResource Frame1Image}"/> 
      <DiscreteObjectKeyFrame KeyTime="0:0:0.03" Value="{Binding Source={StaticResource Frame2Image}"/> 
      <DiscreteObjectKeyFrame KeyTime="0:0:0.06" Value="{Binding Source={StaticResource Frame3Image}"/> 
      <!-- etc --> 
     </ObjectAnimationUsingKeyFrames>    
    </Storyboard> 
</BeginStoryboard>