C# Windows Phone 8.1-设置listview项目的动画
我有一段代码可以正常工作:启动时,LstDevices列表视图在1秒内变得透明C# Windows Phone 8.1-设置listview项目的动画,c#,listview,animation,windows-phone-8.1,C#,Listview,Animation,Windows Phone 8.1,我有一段代码可以正常工作:启动时,LstDevices列表视图在1秒内变得透明 private void DoAnimation() { Storyboard s = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.To = 0; doubleAnimation.Duration =
private void DoAnimation()
{
Storyboard s = new Storyboard();
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.To = 0;
doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
Storyboard.SetTarget(doubleAnimation, LstDevices);
Storyboard.SetTargetProperty(doubleAnimation, "Opacity");
s.Children.Add(doubleAnimation);
s.Begin();
}
事实上,我需要这个列表视图来做两件不同的事情:
1设置ListView的动画,使其不可见,而是通过移出屏幕而消失。
2下一步,如果我滑动单个项目,则该项目应通过移动到屏幕外而消失
DoubleAnimation doubleAnimation = new DoubleAnimation();
itemToAnimate.RenderTransform = (Transform)new TranslateTransform();
事实上,我找不到修改需要移动的项目的X和Y位置的属性。
有人有什么想法吗?我认为使用带双动画的TranslateTransform最容易做到这一点。您可以随时间使用Double动画更改X和Y值,以提供屏幕外移动的外观
DoubleAnimation doubleAnimation = new DoubleAnimation();
itemToAnimate.RenderTransform = (Transform)new TranslateTransform();
然后当我必须设定目标的时候
Storyboard.SetTarget((Timeline)doubleAnimation, (DependencyObject)itemToAnimate.RenderTransform);
谢谢你的回答!请,你能提供一些代码作为例子吗?找到了答案!我使用这个DoubleAnimation DoubleAnimation=新的DoubleAnimation;itemToAnimate.RenderTransform=Transformnew TranslateTransform;然后,当我必须设置target Storyboard.SetTargetTimelinedoubleAnimation时,DependencyObjectitemToAnimate.RenderTransform;很高兴听到这个消息,我正准备研究这个问题,找到了你的答案。