0

这是我的 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

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

4

1 回答 1

0

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

myDoubleAnimation.SetValue(Storyboard.TargetNameProperty, myGrid.Name);
于 2013-02-05T20:02:13.587 回答