This project has moved and is read-only. For the latest updates, please go here.

Silverlight GestureService and EventToCommand

Jan 6, 2011 at 11:30 AM
Edited Jan 6, 2011 at 11:37 AM

Hi, I am using WP7 with mvvmlight, I have ItemsControl that have a DataTemplate given below. i wanted to trap Hold event on border and wire it up using Behaviour EventToCommand. But seems like Interaction Trigger can't be attached to GestureService because its not Dependency Property. Please Help me how can i attach command to Hold event of GestureService

                            <Border x:Name="brdItem" Background="White" Margin="5" Tag="{Binding}">
                                    <toolkit:GestureListener >
                                            <Custom:EventTrigger EventName="Hold">

                                <TextBlock Foreground="Black" Text="{Binding Desc}"/>



Jan 6, 2011 at 12:06 PM


I have a half-written blog post about that. Unfortunately, the GestureService is not very command-friendly. In the moment, the only way I found is to handle the event in the code-behind and to invoke the Command from there.

If you want, you can place the GestureService inside the ListBox (or other data control you're using) and handle the event when it is routed. This allows simplifying the DataTemplate, and keeping it loose from the event handler in the code behind.

Makes sense?



Jan 6, 2011 at 1:10 PM

thanks for the quick reply. I wanted to keep my code behid clear.. but i didn't get how to get routed event from DataTemplate to Its ParentControl? can u point me some article where i can read about it?


Sep 19, 2011 at 9:16 AM

I recently started playing with WP7 and like yourself, I would like to keep my code behind as clean as possible. I have created a behaviour that allows easy addition of the GestureListener. 

Eg. <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