Silverlight for Windows Phone 7 is version 3.7 hence a WP7 control should be easily used within a standard Silverlight 4 application. But that’s in theory. The major differences between these two worlds are the so called “Manipulation” events. Each UIElement in WP7’s Silverlight is “enabled” with the following routed events:
Generally this sequence of events encapsulates one or more touch gestures in a transaction block. The event arguments carry all the information needed to determine what the gesture is and what effect to generate. And of course RadControl for WP7 use these events extensively in order to provide consistent and rich user experience throughout the entire framework.
But what about running these controls in a standard Silverlight Application where the manipulation events are not present? The solution is to generate the gestures manually, depending on mouse input – meet the ManipulationBehavior class we have created to enable standard single-touch gestures outside the WP7 context. The behavior itself attaches to a valid UIElement instance and hooks its MouseLeftButtonDown, MouseMove, MouseLeftButtonUp and MouseLeave events. When mouse input is received, the behavior generates the appropriate gestures and raises one or more of the following events:
In order to determine whether a flick gesture should be generated we calculate the timespan between the last mouse move and the MouseLeftButtonUp event:
Point current = e.GetPosition(Application.Current.RootVisual);
ManipulationTapEventArgs args =
.lastMoveTime.TotalMilliseconds <= FlickTimeSpan)
// less than 10 milliseconds between a mousemove and left button release is considered as a Flick gesture
ManipulationFlickEventArgs args =
And here is how the velocity is calculated:
offsetY = currentPosition.Y -
milliseconds = DateTime.Now.TimeOfDay.TotalMilliseconds -
// speed (pixels per millisecond)
panSpeed = offsetY / milliseconds;
(panSpeed == 0)
height / 2;
panSpeed * height * 1.5d;
Well, enough words, you’d better see it for yourself (this is not just a picture :)
Please note that the text here looks a bit different than in WP7 because the Segoe WP Font is installed with the Windows Phone 7 tools and we have intentionally specified the standard Segoe UI Font for the demo.
Do not hesitate to read more about our RadControls for WP7 and to grab a copy of our fresh CTP release. Any feedback is most welcome.