Im now designing a UWP and I want to add a swipe gesture to open my Hamburger Menu. However, in one of my pages I add in a pivot, and then the swipe gesture doesn't open the Menu, instead it switches the PivotItem.
How to make them both alive in the same page?
here is my code about swipe gesture: (thx to http://blog.csdn.net/github_36704374/article/details/59580697)
namespace Humberger
{
public sealed partial class MainPage : Page
{
private double x = 0; //用来接收手势水平滑动的长度
public MainPage()
{
this.InitializeComponent();
this.ManipulationMode = ManipulationModes.TranslateX; //设置这个页面的手势模式为横向滑动
this.ManipulationCompleted += The_ManipulationCompleted; //订阅手势滑动结束后的事件
this.ManipulationDelta += The_ManipulationDelta; //订阅手势滑动事件
}
//手势滑动中
private void The_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
x += e.Delta.Translation.X; //将滑动的值赋给x
}
//手势滑动结束
private void The_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (x > 100) //判断滑动的距离
MySplit.IsPaneOpen = true; //打开汉堡菜单
if (x < -100)
MySplit.IsPaneOpen = false; //关闭汉堡菜单
x = 0; //清零x,不然x会累加
}
//汉堡菜单点击事件
private void Humberger_Click(object sender, RoutedEventArgs e)
{
MySplit.IsPaneOpen = !MySplit.IsPaneOpen;
}
}
}