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();

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

  • 相关阅读:
    rest framework 认证 权限 频率
    rest framework 视图,路由
    rest framework 序列化
    10.3 Vue 路由系统
    10.4 Vue 父子传值
    10.2 Vue 环境安装
    10.1 ES6 的新增特性以及简单语法
    Django 跨域请求处理
    20190827 On Java8 第十四章 流式编程
    20190825 On Java8 第十三章 函数式编程
  • 原文地址:https://www.cnblogs.com/socialdk/p/2694348.html
Copyright © 2011-2022 走看看