How to trigger an EventToCommand from a GestureListener.Gesture

久未见 提交于 2019-12-10 16:52:29

问题


Has anyone used a Toolkit.GestureListener to fire an EventToCommand?


回答1:


I don't think you can do it with the EventToCommand behaviour but I have created a behaviour that allows easy addition of the GestureListener by binding them to a command.

<Button  Content="Start"  
 Behaviour:GestureListenerBehaviours.TapCommand="{Binding   StartCommand}" />

I have only mapped the tap and the double tap but it should be easy to map the rest if required. Have a look at this link to get the source code

http://lazycowprojects.tumblr.com/post/10397441921/gesturelistenerbehaviourswp7




回答2:


It is not currently possible. GestureListener.Tap does not support this. I have an event handler in my code behind, which calls viewmodel method using datacontext:

 private void OnListItemTap(object sender, GestureEventArgs e)
 {
     var vm = DataContext as MyViewModel;
     if (vm != null)
     {
         vm.TapOnItem.Execute(listbox.SelectedItem);
     }
 }


来源:https://stackoverflow.com/questions/3813608/how-to-trigger-an-eventtocommand-from-a-gesturelistener-gesture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!