c# - 在 Windows 应用商店应用程序 [XAML/C#] 中淡入/淡出 TextBlock

标签 c# xaml animation windows-8 visual-studio-2012

有人可以解释一下当我在 Windows 应用商店应用程序中加载表单时如何向文本 block 添加淡入和淡出动画吗? 我尝试了 WPF 方法,但它没有用...... 谢谢:)

最佳答案

不确定这是否是您要查找的内容(或者“WPF 方法”无效的原因),但使用此资源:

<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>

OnNavigatedTo 调用你会得到淡入效果(这里是在一个名为 textBlock 的特定实例上。)显然,你可以根据自己的喜好调整持续时间和缓动函数 - 并且可能概括为在各种控件中使用。

var f = this.Resources["Storyboard1"] as Storyboard;
if (f != null) f.Begin();

关于c# - 在 Windows 应用商店应用程序 [XAML/C#] 中淡入/淡出 TextBlock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13532501/

相关文章:

java - 可以在迭代过程中改变的可迭代集合

c# - 将图像上传到 ASP.NET MVC 网站并将其保存在数据库中

c# - 将 DataGrid 的 FontWeight 属性绑定(bind)到值转换器

wpf - 如何在WPF窗口中触发Usercontrol的Unload事件

带有按钮 View 问题的Android TranslateAnimation

c# - 使用没有 certificateValidationMode 的证书时出现 WCF SecurityNegotiationException

xaml - Silverlight Xaml 和资源中的 StringFormat

python - 如何获取利萨如曲线表中所有曲线的X和Y位置?

android - LinearLayout animate() 剪辑 View ,clipChildren 不起作用

c# - 单例 - 我可以创建多个实例