如何将MSGesture事件添加到listview [英] How to add MSGesture Event to listview
问题描述
我试图将MSGesture事件添加到我的列表视图中以跟踪列表视图上的手指滑动。
I was trying to add MSGesture Event to my listview to track the finger swipe on the listview.
下面是我用来创建列表视图的代码。
Below is the code I used to create the listview.
var elem = document.createElement('div');
var elem = document.createElement('div');
elem.id ='mylist';
elem.id = 'mylist';
var lv = new WinJS.UI.ListView(elem,{ });
var lv = new WinJS.UI.ListView(elem, { });
然后我尝试使用以下代码进行连接事件处理程序
Then I tried the following code to hook up the event handler
var list = document.getElementById(" mylist");
var list = document.getElementById("mylist");
list .addEventListener(" MSGestureEnd",eventhandler,false );
list .addEventListener("MSGestureEnd", eventhandler, false);
var myGesture = new MSGesture();
myGesture .target = list;
var myGesture = new MSGesture();
myGesture .target = list ;
但事件永远不会被解雇了。
However the event never got fired.
知道如何让这个工作吗?
Any idea how to make this working?
非常感谢!
推荐答案
您好,我认为正确的代码是
Hello, I think that the correct code is
var list = document.getElementById("mylist");
list .addEventListener("MSGestureEnd", eventhandler, false);
var myGesture = new MSGesture();
myGesture.target = list;
myGesture.srcElt = list;
list.gesture = myGesture;
list.gesture.pointerType = null;
这篇关于如何将MSGesture事件添加到listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!