【问题标题】:Cannot use DoubleAnimation.SetValue method in Windows 8 store App无法在 Windows 8 商店应用程序中使用 DoubleAnimation.SetValue 方法
【发布时间】:2013-01-20 20:55:50
【问题描述】:

这是我的 XAML 代码,

     <Grid>
         <Grid.Resources>
              <Storyboard x:Name="myStoryboard">
                   <DoubleAnimation x:Name="myDoubleAnimation" Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:0.2" AutoReverse="True"/>
               </Storyboard>
          </Grid.Resources>

          <Grid x:Name="op_food" PointerEntered="op_PointerEntered">
                <TextBlock Text="Food"/>
          </Grid>

          <Grid x:Name="op_cineplex" PointerEntered="op_PointerEntered">
               <TextBlock Text="Cineplex"/>
          </Grid>
     </Grid>

还有C#函数,

    private void op_PointerEntered(object sender, PointerRoutedEventArgs e)
    {
        myStoryboard.Stop();
        Grid myGrid = (Grid)sender;
        myDoubleAnimation.SetValue(Storyboard.TargetProperty,myGrid.Name);
        myStoryboard.Begin();
    }

现在这是我执行此任务所遵循的链接,智能感知无法找到情节提要 -> http://blogs.msdn.com/b/silverlight_sdk/archive/2008/03/26/target-multiple-objects-properties-with-one-animation-silverlight.aspx

那么我在这段代码中哪里错了???

【问题讨论】:

    标签: c# windows storyboard


    【解决方案1】:

    我相信您正在寻找Storyboard.TargetNameProperty,而不是“TargetProperty”(您正在尝试设置要设置动画属性的元素的名称,而不是属性名称本身)。

    myDoubleAnimation.SetValue(Storyboard.TargetNameProperty, myGrid.Name);
    

    【讨论】:

    • 这是我面临的问题....每当我编写 Storyboard 及其相关属性时,它都会显示此错误:当前上下文中不存在名称“Storyboard”。
    • 对不起...我没有在程序中包含 Media.Animation
    • 我将 Media.Animation 包含在项目中,但仍然面临这个问题......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-30
    • 1970-01-01
    相关资源
    最近更新 更多