如何使用渐弱效果淡化项目

时间:2014-09-21 17:18:23

标签: animation windows-phone-8 fadein fadeout

根据某些标准,我需要淡入或淡出页面屏幕顶部的项目。这些项目包含一个Image,将来可能包含一些按钮。我在WP8.1中遇到了http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.media.animation.edgeuithemetransition.aspx,但是如何在WP8.0中实现这一点?

1 个答案:

答案 0 :(得分:0)

您应该使用Blend创建自己的自定义动画。可以通过调整控件的不透明度级别来实现淡入或淡出。您可以按照link进行操作。另一个link

例如,如果您想对图像应用淡入效果,则此处为示例代码。

<phone:PhoneApplicationPage.Resources>
    <Storyboard x:Name="fadeInImage">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="image">
            <EasingDoubleKeyFrame KeyTime="0" Value="0.1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.3"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0.5"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0.7"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0.9"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</phone:PhoneApplicationPage.Resources>

并且为了播放该动画,必要时调用它,

fadeInImage.Begin();
相关问题