基于Windows Phone的Silverlight低级别触屏处理
element含义在Silverlight编程中element有两个含义,1.表示XML中的标签,2.表示界面中显示的对象,即UIElement,UIElement是非常重要的一个基类,所有的控件,如Grid, TextBlock, Button, Image等都集成于UIElement。
Silverlight触屏
Silverlight可分为低级别和高级别两个接口,其中,高级别接口通过UIElement类的三个事件处理实现的的:ManipulationStarted, ManipulationDelta, ManipulationCompleted;而低级别接口通过Touch.FrameReported实现的。
其中Silverlight触屏接口最重要的一个类是TouchPoint,一个TouchPoint代表一个指头触摸屏幕。
TouchPoint有4个只读属性:
http://images.51cto.com/files/uploadimg/20120202/1637430.jpgTouchPoint的只读属性
使用低级别触屏街口的话,需要在程序中注册事件处理函数:
Touch.FrameReported += OnTouchFrameReported;
一般我们可以把这行代码放到页面的构造函数中
OnTouchFrameReported函数原型为:void OnTouchFrameReported(object sender, TouchFrameEventArgsargs){ }
这个处理函数里面,可以通过TouchFrameEventArgs的以下三种方法获得我们想要相关的信息
1.GetTouchPoints获得所有的触摸坐标,返回的是TouchPointCollection,多点触摸这可以通过这个判断
2.GetPrimaryTouchPoint只返回一个TouchPoint
3.SuspendMousePromotionUntilToucnUp,这个成员函数的具体含义大家查阅MSDN即可。
【编辑推荐】
[*]Windows Phone 7开发之Silverlight游戏编辑器
[*]基于Silverlight的Menlo 微软跨平台移动应用新利器
[*]Windows Phone 7中用好Silverlight开发利器
[*]微软云存储服务SkyDrive弃Silverlight用HTML 5
[*]杨亨冉:用Silverlight实现跨平台游戏开发
[*]解析:Silverlight控件模型分类及XAML特性
页:
[1]