htbzwd 发表于 2015-5-23 10:51:44

Windows Phone开发经验谈(8)-手势切换的方式(下)

  继上篇Windows Phone开发经验谈(7)-手势切换的方式(上)后,我继续来给大家说说如何在切换的过程中加入动画...
  首先来说说思路首先一个页面的切换需要有过渡动画,我们可以考虑用3个不同的容器之间进行切换.默认的要显示第2的这个容器.左边滑动的时候第1个容器跑到中间 右边滑动的时候第2个容器跑到中间.
  xaml代码如下:






            




























































  
  后台代码如下



using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace PhoneApp3
{
public partial class MainPage : PhoneApplicationPage
{

Dictionary dic = new Dictionary();
public MainPage()
{
InitializeComponent();
dic.Add(0, zero);
dic.Add(1, one);
dic.Add(2, two);
Init.Begin();
}
private void ContentPanel_MouseLeave(object sender, MouseEventArgs e)
{
}

private void LayoutRoot_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
Point point = e.GetPosition(LayoutRoot);
if (point.X0.0)
{
prev();
}
else
{
next();
}
}
}
}
}

  
  上面的代码就是首先初始化让中间的位置的显示,然后上一个就是左边的移动到中间来让他显示,下一个是右边的移动到中间让他显示...
  原理很简单..项目我也打包好,大家研究一下.PhoneApp3.rar
页: [1]
查看完整版本: Windows Phone开发经验谈(8)-手势切换的方式(下)