Exposing Manipulation Events

An individual control can be extended to emit Manipulation Events via the Manipulate2DBehavior class. This class is exposed as a Silverlight Behavior. More information on Silverlight Behaviors can be found at http://team.silverlight.net/tips-and-training/interactivity-without-code/

The typical way to attach this behavior to the desired control is in the Xaml markup itself, as seen below:
<Rectangle x:Name="RedRect" Width="200" Height="200" Fill="Red">
	<Rectangle.RenderTransform>
		<TranslateTransform Y="-200"/>
	</Rectangle.RenderTransform>
	<i:Interaction.Behaviors>
		<Touch:Manipulate2DBehavior  
			IsInertial="True"
			ManipulationStarted="TouchShapeBehavior_ManipulationStarted" 
			ManipulationDelta="TouchShapeBehavior_ManipulationDelta"
			ManipulationCompleted="TouchShapeBehavior_ManipulationCompleted"/>
	</i:Interaction.Behaviors>
</Rectangle>

The IsInertial parameter determines whether or not Inertia is applied to the motion (which results in added ManipulationDelta events being fired after the actual touch has been concluded.)

The Manipulation events themselves report the following information in their event arguments:
  • ManipulationStarted
    • OriginX, OriginY - the position where the manipulation originated
  • ManipulationDelta
    • OriginX, Origin Y - the position where the manipulation originated
    • Velocities - The current velocities as they apply to the manipulation (Linear, Angular, Expansion)
    • Delta - Translation, Rotation, Scale, and Expansion details for the current event
    • Cumulative - This is the cumulative delta information tracked since the manipulation started - the net delta
  • ManipulationCompleted
    • OriginX, Origin Y - the position where the manipulation originated
    • Velocities - The net velocity for the lifetime of the manipulation
    • Total - The net Delta information for the lifetime of the manipulation

Last edited Apr 3, 2011 at 2:42 AM by avidgator, version 3

Comments

No comments yet.