介紹
重新想象 Windows 8 Store Apps 之 手勢
監測側邊手勢
手勢操作 - Manipulate 的應用(位移手勢,縮放手勢,旋轉手勢)
手勢識別 - GestureRecognizer 的應用
樣本
1、示範如何監測側邊手勢
Input/Touch/EdgeGestureDemo.xaml
<Page x:Class="XamlDemo.Input.Touch.EdgeGestureDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:XamlDemo.Input.Touch" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="Transparent"> <StackPanel Margin="120 0 0 0"> <TextBlock Name="lblMsg" FontSize="14.667" /> </StackPanel> </Grid></Page>
Input/Touch/EdgeGestureDemo.xaml.cs
/* * 示範如何監測側邊手勢 * * EdgeGesture - 側邊手勢的協助類 * GetForCurrentView() - 擷取當前的 EdgeGesture 對象 * Starting - 側邊手勢開始時觸發的事件 * Completed - 側邊手勢完成後觸發的事件 * Canceled - 側邊手勢取消後觸發的事件 * * EdgeGestureEventArgs - 觸發側邊手勢事件後的事件參數 * EdgeGestureKind - 側邊手勢的輸入類型(Touch, Keyboard, Mouse) */ using System;using Windows.UI.Input;using Windows.UI.Xaml.Controls; namespace XamlDemo.Input.Touch{ public sealed partial class EdgeGestureDemo : Page { public EdgeGestureDemo() { this.InitializeComponent(); EdgeGesture edgeGesture = EdgeGesture.GetForCurrentView(); edgeGesture.Canceled += edgeGesture_Canceled; edgeGesture.Completed += edgeGesture_Completed; edgeGesture.Starting += edgeGesture_Starting; } void edgeGesture_Starting(EdgeGesture sender, EdgeGestureEventArgs args) { lblMsg.Text += "EdgeGesture Starting"; lblMsg.Text += Environment.NewLine; } void edgeGesture_Completed(EdgeGesture sender, EdgeGestureEventArgs args) { lblMsg.Text += "EdgeGesture Completed"; lblMsg.Text += Environment.NewLine; } void edgeGesture_Canceled(EdgeGesture sender, EdgeGestureEventArgs args) { lblMsg.Text += "EdgeGesture Canceled"; lblMsg.Text += Environment.NewLine; } }}