问题
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