用于动画的xaml代码的C#等价物

用于动画的xaml代码的C#等价物,c#,xaml,windows-phone-7,animation,windows-phone-8,C#,Xaml,Windows Phone 7,Animation,Windows Phone 8,我为一个名为“rect”的矩形使用expression blend创建了这个小动画 现在,我想为运行时加载的每个listbox项(使用itemtemplate生成)显示此动画,如何设置listitems的animate属性。如何为列表项指定TargetName属性? 如果这不可能,那么我想知道如何在C#中转换上述代码 您可以在ItemTemplate中定义情节提要,使每个项目都有自己的内容,并使用EventTrigger启动加载的事件和操作来启动情节提要。将情节提要定义为DataTempla

我为一个名为“rect”的矩形使用expression blend创建了这个小动画


现在,我想为运行时加载的每个listbox项(使用itemtemplate生成)显示此动画,如何设置listitems的animate属性。如何为列表项指定
TargetName
属性?
如果这不可能,那么我想知道如何在C#中转换上述代码

您可以在ItemTemplate中定义情节提要,使每个项目都有自己的内容,并使用EventTrigger启动加载的事件和操作来启动情节提要。将情节提要定义为DataTemplate中第一个元素的资源,以便您可以访问命名元素(如)。

这可能会对您有所帮助

DoubleAnimation rotation = new DoubleAnimation();
            rotation.From = 0;
            rotation.To = 90;
            rotation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            Storyboard.SetTarget(rotation, rect);
            Storyboard.SetTargetProperty(rotation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)"));
            Storyboard flipanim= new Storyboard();
            flipanim.Children.Add(rotation);
            flipanim.Begin();
DoubleAnimation rotation = new DoubleAnimation();
            rotation.From = 0;
            rotation.To = 90;
            rotation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            Storyboard.SetTarget(rotation, rect);
            Storyboard.SetTargetProperty(rotation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)"));
            Storyboard flipanim= new Storyboard();
            flipanim.Children.Add(rotation);
            flipanim.Begin();