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 :)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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>
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();