为什么故事板的价值也不会从资源或结合得到什么? [英] Why Storyboard value wouldn't get from a resource or binding?

查看:151
本文介绍了为什么故事板的价值也不会从资源或结合得到什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下建筑和它的作品:

I have construction below and it works:

 <Storyboard x:Key="GrowOnStart">
   <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="window">
            <EasingDoubleKeyFrame KeyTime="0" Value="1024"/>

为什么,如果我尝试这样的事情它不工作:

Why it doesn't work if I try something like this:

  <EasingDoubleKeyFrame KeyTime="0" Value="{DynamicResource StartingPositionLeft}"/>

是的,我定义的故事板前的资源。
而像下一个语句是行不通之一:

And yes, I defined the resource before the storyboard. And the statement like the next one wouldn't work either:

 <EasingDoubleKeyFrame KeyTime="0" Value="{Binding StartingPositionLeft}"/>

是的它是在code的公共属性后面和 this.DataContext 设置为这个

推荐答案

这是因为动画可冻结对象。有一个在 MSDN文档的更多信息,但基本上它意味着你可以'T使用绑定,因为在冰冻对象属性(即动​​画),不能更改。

This is because Animations are freezable objects. There is more information in the MSDN Documentation, but basically it means you can't use binding because properties in the frozen object (i.e. the animation) cannot change.

要解决这个限制,你需要做一些或所有的工作在code-落后。

To get around this limitation, you will need to do some or all of the work in code-behind.

这篇关于为什么故事板的价值也不会从资源或结合得到什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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