2
現在我正在設計UWP並且想要添加滑動手勢來打開我的漢堡菜單。但是,在我的一個頁面中添加了一個數據透視表,然後滑動手勢不會打開菜單,而是切換PivotItem。在UWP中存在關鍵點時,滑動手勢不起作用
如何讓它們在同一個頁面中都活着?
這裏是我講的滑動手勢代碼: (感謝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;
}
}
}
是的,'Pivot'會吞下你所有的水平用戶輸入。訣竅是給它一個'1'的左邊距。這將允許您從父頁面的左邊緣滑動。 –