淡入/淡出Windows Store应用程序中的TextBlock [XAML / C#] [英] Fade in/out a TextBlock in a Windows Store Application [XAML/C#]
问题描述
有人可以解释一下我在Windows Store应用程序中加载表单时如何在文本块中添加淡入和淡出动画吗?
我尝试了WPF方法,但是没有用...
谢谢:)
can someone explain me how can I add a fade in and a fade out animation to a textblock when I load a form in a Windows Store application? I tried the WPF method but it didn't work... Thank you :)
推荐答案
不确定这是否是您要查找的内容(或什么 WPF方法不起作用),但是具有以下资源:
Not sure if this is what you're looking for (or what "WPF method" didn't work), but with this resource:
<Page.Resources>
<Storyboard x:Name="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textBlock">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
淡入效果(在这里称为textBlock的特定实例。)显然,您可以根据自己的喜好调整持续时间和缓动功能-并可以泛化以便在各种控件中使用。
invoked from OnNavigatedTo
you'll get a fade-in effect (here on a specific instance called textBlock.) Obviously, you can adjust the duration and easing function to your liking - and perhaps generalize for use across various controls.
var f = this.Resources["Storyboard1"] as Storyboard;
if (f != null) f.Begin();
这篇关于淡入/淡出Windows Store应用程序中的TextBlock [XAML / C#]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!