使用KeyTime值作为资源 [英] Use KeyTime value as resource

查看:137
本文介绍了使用KeyTime值作为资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有情节提要:

    <Storyboard x:Key="St1">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="imageBlue">
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

我会想提取keyTime值,某处放置。换句话说,我一直在努力使这项工作:

I will like to extract the keyTime value and place it somewhere. In other words I been trying to make this work:

<UserControl.Resources>

    <sys:TimeSpan x:Key="FadeInBeginTime">0:0:2</sys:TimeSpan>
    <Duration x:Key="FadeInDuration">0:0:1</Duration>

    <Storyboard x:Key="St1">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="imageBlue">
            <EasingDoubleKeyFrame KeyTime={StaticResource FadeInDuration}" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</UserControl.Resources>

请注意我使用的命名空间:

note I am using the namespace:

xmlns:sys="clr-namespace:System;assembly=mscorlib" 

由于某种原因不能正常工作

for some reason that does not work

推荐答案

您应该指定FadeInDuration作为KeyTime不是一个时间跨度

You should specify the FadeInDuration as a KeyTime not a TimeSpan

即:

<KeyTime x:Key="FadeInBeginTime">0:0:2.0</KeyTime>

这篇关于使用KeyTime值作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆