代码之家  ›  专栏  ›  技术社区  ›  iLemming

为什么脚本值不能从资源或绑定中获得?

  •  1
  • iLemming  · 技术社区  · 14 年前

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

    如果我尝试这样的方法,它为什么不起作用:

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

    是的,我在情节提要之前定义了资源。

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

    是的,这是一个公共财产 此.DataContext 设置为

    1 回复  |  直到 14 年前
        1
  •  2
  •   Wonko the Sane    14 年前

    这是因为动画是可自由化的对象。报告中有更多信息 MSDN Documentation ,但基本上这意味着不能使用绑定,因为冻结对象(即动画)中的属性不能更改。

    要绕过这个限制,您需要在代码隐藏中完成部分或全部工作。