在我上一个BLOG中写到了滑动时不会触发ListBoxItem,同样接着上一个例子,我如果需要做一个分页滑动的效果的话,首先要有滑动的效果,我觉得如果是分页的话,那一个页面中肯定是固定Item数目,然后在Canvas中放入3个一样的ListBox分别把Canvas.left设置为你的窗口大小左右都放一个,中间放一个=-= 然后根据上个例子一样往左拉都触发动画效果让中间和右边的Lis-tBox同时往左移动,最后再把动画还原就可以了。这样就可以实现拖动效果,然后Item里面的数据的话只要每次滑动的时候在中间的那个ListBox中变化就可以了(这个东西下次再写)。
动画的实现的话代码如下:
View Code
Storyboard storyboard = new Storyboard(); DoubleAnimation doubleanimation = new DoubleAnimation(); doubleanimation.To = 0; doubleanimation.Duration = TimeSpan.FromSeconds(0.5); Storyboard.SetTarget(doubleanimation, listBox3); Storyboard.SetTargetProperty(doubleanimation, new PropertyPath("(Canvas.Left)")); storyboard.Children.Add(doubleanimation); storyboard.FillBehavior = FillBehavior.Stop; storyboard.Begin(); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.To = 525; doubleAnimation.Duration = TimeSpan.FromSeconds(0.5); Storyboard.SetTarget(doubleAnimation, listBox1); Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)")); storyboard.Children.Add(doubleAnimation); storyboard.FillBehavior = FillBehavior.Stop; storyboard.Begin();
虽然比较简陋= =但是勉强能够实现滑动效果~等下次学点高级的东西再改进吧。。。