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);
}
}
标签:
mvvm-light