zoukankan      html  css  js  c++  java
  • WPF最简单的动画滑动效果

      在我上一个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();

    虽然比较简陋= =但是勉强能够实现滑动效果~等下次学点高级的东西再改进吧。。。

  • 相关阅读:
    机器学习公开课笔记第八周之推荐系统
    使用RT3070使开发板上网
    Linux及FL2440使用过程遇到的各种问题和小技巧
    学习 Git的使用过程
    Linux下Bash shell学习笔记
    MarkDown学习笔记
    STM32F407+STemwin学习笔记之STemwin移植补充Touch
    STM32F407+STemwin学习笔记之STemwin移植
    DXP常用的设置及快捷键
    第九届蓝桥杯-嵌入式比赛体会与备赛经验
  • 原文地址:https://www.cnblogs.com/socialdk/p/2694348.html
Copyright © 2011-2022 走看看