VisualInteractionSource VisualInteractionSource VisualInteractionSource VisualInteractionSource Class

Definition

Object for configuring input to the InteractionTracker relative to a visual.

The VisualInteractionSource is designed to be used only with InteractionTracker and defines which input will be sent to the InteractionTracker to drive its state and properties. This class contains both the visual to be used for hit-testing, as well as a variety of configuration properties for which gestures and types of input will be sent to the InteractionTracker.

public : class VisualInteractionSource : CompositionObject, ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2, IVisualInteractionSource3
struct winrt::Windows::UI::Composition::Interactions::VisualInteractionSource : CompositionObject, ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2, IVisualInteractionSource3
public class VisualInteractionSource : CompositionObject, ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2, IVisualInteractionSource3
Public Class VisualInteractionSource Inherits CompositionObject Implements ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2, IVisualInteractionSource3
Inheritance
VisualInteractionSourceVisualInteractionSourceVisualInteractionSourceVisualInteractionSource
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Examples


void SetupSimpleInteractionTracker(Visual viewportVisual, Visual contentVisual)
{
  //
  // Create the InteractionTracker and set its min/max position and scale.  These could 
  // also be bound to expressions.  Note: The scrollable area can be changed from either 
  // end to facilitate content updates/virtualization.
  //

  _tracker = InteractionTracker.Create(_compositor);

  _tracker.MaxPosition = new Vector3(
    contentVisual.Size.X - viewportVisual.Size.X,
    contentVisual.Size.Y - viewportVisual.Size.Y,
    0.0f);

  _tracker.MinScale = 0.5f;
  _tracker.MaxScale = 4.0f;


  //
  // Configure the interaction source.  Enable input with inertia on all axis.
  //

  var interactionSource = VisualInteractionSource.Create(viewportVisual);

  interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;
  interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia;
  interactionSource.ScaleSourceMode = InteractionSourceMode.EnabledWithInertia;

  _tracker.InteractionSources.Add(interactionSource);


  //
  // Bind the InteractionTracker outputs to the contentVisual.
  //

  var positionExpression = _compositor.CreateExpressionAnimation("-tracker.Position");
  positionExpression.SetReferenceParameter("tracker", _tracker);

  contentVisual.StartAnimation("Offset", positionExpression);


  var scaleExpression = _compositor.CreateExpressionAnimation("Vector3(tracker.Scale, tracker.Scale, 1.0)");

  scaleExpression.SetReferenceParameter("tracker", _tracker);

  contentVisual.StartAnimation("Scale", scaleExpression);
}

Remarks

The VisualInteractionSource is used to define important properties about the types of interactions that should drive the InteractionTracker’s state and properties. The source property is used both for hit-testing, as well as the coordinate space for gesture detection. As a result, it is important to use a Visual that is not going to be in motion during the manipulation. Multiple VisualInteractionSources can be associated with the same InteractionTracker if there are multiple hit-test regions, but the most common cases require only one VisualInteractionSource for a given InteractionTracker.

VisualInteractionSource is the class for configuring which types of gestures should be considered for driving the InteractionTracker. Position X and Y are associated with horizontal and vertical panning respectively. Scale is detected with a pinch gesture, often associated with zooming. These three source modes are all configurable for touch and Precision Touchpad input. Each of these source modes can be enabled with or without inertia. Enabling inertia indicates that position or scale will naturally interpolate from the release velocity to no velocity during the inertia state. Disabling inertia indicates that position or scale velocity will immediately go to 0 upon completion of the interaction. When input that drives position or scale is routed to the InteractionTracker, the InteractionTracker property of the same name will be updated appropriately.

The rails configurations indicate how the gesture will be detected. Turning on rails indicates that the horizontal or vertical pan will lock to a particular axis when started primarily on that axis. This is explained in more detail on the railing property pages.

The chaining configuration indicates whether input that is processed by one VisualInteractionSource can flow to another entity when the InteractionTracker reaches the min or max in that direction. This configuration will allow input to chain to either another InteractionTracker via another VisualInteractionSource, or to a ScrollViewer if the VisualInteractionSource’s source visual is a child of the ScrollViewer.

Properties

Comment Comment Comment Comment

A string to associate with the CompositionObject.

(Inherited from CompositionObject)
Compositor Compositor Compositor Compositor

The Compositor used to create this CompositionObject.

(Inherited from CompositionObject)
DeltaPosition DeltaPosition DeltaPosition DeltaPosition

The amount of position change to be applied during the upcoming frame. Defaults to 0. Readable only via expression/animation.

DeltaScale DeltaScale DeltaScale DeltaScale

The amount of scale change to be applied during the upcoming frame. Multiplicative. Defaults to 1. Readable only via expression/animation.

Dispatcher Dispatcher Dispatcher Dispatcher

The dispatcher for the CompositionObject.

(Inherited from CompositionObject)
DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Gets the DispatcherQueue for the CompostionObject.

(Inherited from CompositionObject)
ImplicitAnimations ImplicitAnimations ImplicitAnimations ImplicitAnimations

The collection of implicit animations attached to this object.

(Inherited from CompositionObject)
IsPositionXRailsEnabled IsPositionXRailsEnabled IsPositionXRailsEnabled IsPositionXRailsEnabled

Indicates whether panning on the x-axis is railed.

The IsPositionXRailsEnabled property defines the railing configuration for when X-axis panning gets sent to the corresponding InteractionTracker. When enabled, if the initial part of the pan is angled within a particular range relative to the X-axis, the Y component of the pan is ignored and considered a perfect horizontal pan. This property is often enabled in situations where both an X and Y scrolling experience is enabled, but also requires reliable, perfect horizontal panning.

IsPositionYRailsEnabled IsPositionYRailsEnabled IsPositionYRailsEnabled IsPositionYRailsEnabled

Indicates whether panning on the y-axis is railed.

The IsPositionYRailsEnabled property defines the railing configuration for when Y-axis panning gets sent to the corresponding InteractionTracker. When enabled, if the initial part of the pan is angled within a particular range relative to the Y-axis, the X component of the pan is ignored and considered a perfect vertical pan. This property is often enabled in situations where both an X and Y scrolling experience is enabled, but also requires reliable, perfect vertical panning.

ManipulationRedirectionMode ManipulationRedirectionMode ManipulationRedirectionMode ManipulationRedirectionMode

Indicates what input should be redirected to the InteractionTracker.

PointerWheelConfig PointerWheelConfig PointerWheelConfig PointerWheelConfig
Position Position Position Position

The total amount of position change since the start of the interaction. Defaults to 0. Readable only via expression/animation.

PositionVelocity PositionVelocity PositionVelocity PositionVelocity

The instantaneous rate of change of position in the interaction, in pixels per second. Defaults to 0. Readble only via expression/animation.

PositionXChainingMode PositionXChainingMode PositionXChainingMode PositionXChainingMode

The PositionXChainingMode property defines the chaining behavior for an InteractionSource in the X direction. There are three types of InteractionChainingMode s: Auto , Always , Never . When chaining in the X direction is enabled, input will flow to the nearest ancestor's VisualInteractionSource whenever the interaction (such as panning) would otherwise take InteractionTracker ’s position past its minimum or maximum X position.

PositionXSourceMode PositionXSourceMode PositionXSourceMode PositionXSourceMode

Source mode for the X-axis.

The PositionXSourceMode property defines how interactions are processed for a VisualInteractionSource on the X-axis. There are 3 types of InteractionSourceMode s to choose from: Interactions are Disabled, EnabledWithInertia and EnabledWithoutInertia. This property must be enabled to allow the VisualInteractionSource to send X-axis data to InteractionTracker.

PositionYChainingMode PositionYChainingMode PositionYChainingMode PositionYChainingMode

The PositionYChainingMode property defines the chaining behavior for an InteractionSource in the Y direction. There are three types of InteractionChainingMode s: Auto , Always , Never . When chaining in the Y direction is enabled, input will flow to the nearest ancestor’s VisualInteractionSource whenever the interaction (such as panning) would otherwise take InteractionTracker ’s position past its minimum or maximum Y position.

PositionYSourceMode PositionYSourceMode PositionYSourceMode PositionYSourceMode

Source mode for the Y-axis.

The PositionYSourceMode property defines how interactions are processed for a VisualInteractionSource on the Y-axis. There are 3 types of InteractionSourceMode s to choose from: Interactions are Disabled, EnabledWithInertia and EnabledWithoutInertia. This property must be enabled to allow the VisualInteractionSource to send Y-axis data to InteractionTracker.

Properties Properties Properties Properties

The collection of properties associated with the CompositionObject.

(Inherited from CompositionObject)
Scale Scale Scale Scale

The total percentage-difference in scale since the start of the interaction. Multiplicative. Defaults to 1. Readable only via expression/animation.

ScaleChainingMode ScaleChainingMode ScaleChainingMode ScaleChainingMode

The ScaleChainingMode property defines the chaining behavior for an InteractionSource in the Scale direction. There are three types of InteractionChainingMode s: Auto, Always, Never. When Scale chaining is enabled, input will flow to the nearest ancestor’s VisualInteractionSource whenever the interaction (such as panning) would otherwise take InteractionTracker ’s position past it’s minimum or maximum Scale position.

ScaleSourceMode ScaleSourceMode ScaleSourceMode ScaleSourceMode

Defines how interactions are processed for an VisualInteractionSource on the scale axis. There are 3 types of InteractionSourceMode s to choose from: Interactions are Disabled , EnabledWithInertia and EnabledWithoutInertia . This property must be enabled to allow the VisualInteractionSource to send scale data to InteractionTracker.

ScaleVelocity ScaleVelocity ScaleVelocity ScaleVelocity

The instantaneous rate of change of scale in the interaction, in percent per second. Additive. Defaults to 0. Readble only via expression/animation.

Source Source Source Source

The visual that is used for hit-testing and defines the co-ordinate space for gesture recognition.

Methods

Close Close Close Close

Closes the CompositionObject and releases system resources.

(Inherited from CompositionObject)
ConfigureCenterPointXModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointXModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointXModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointXModifiers(IIterable<CompositionConditionalValue>)

Takes an ordered list of CompositionConditionalValue. In a frame, the first CompositionConditionalValue to have its “.Condition” evaluate to true replaces the zoom CenterPointX value the VisualInteractionSource provides with its “.Value”. If none evaluate to true, the CenterPointX is not replaced that frame.

ConfigureCenterPointYModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointYModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointYModifiers(IIterable<CompositionConditionalValue>) ConfigureCenterPointYModifiers(IIterable<CompositionConditionalValue>)

Takes an ordered list of CompositionConditionalValue. In a frame, the first CompositionConditionalValue to have its “.Condition” evaluate to true replaces the zoom CenterPointY value the VisualInteractionSource provides with its “.Value”. If none evaluate to true, the CenterPointY is not replaced that frame.

ConfigureDeltaPositionXModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionXModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionXModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionXModifiers(IIterable<CompositionConditionalValue>)

Takes an ordered list of CompositionConditionalValue. In a frame, the first CompositionConditionalValue to have its “.Condition” evaluate to true replaces the DeltaPositionX value the VisualInteractionSource provides with its “.Value”. If none evaluate to true, the DeltaPositionX is not replaced that frame.

ConfigureDeltaPositionYModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionYModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionYModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaPositionYModifiers(IIterable<CompositionConditionalValue>)

Takes an ordered list of CompositionConditionalValue. In a frame, the first CompositionConditionalValue to have its “.Condition” evaluate to true replaces the DeltaPositionY value the VisualInteractionSource provides with its “.Value”. If none evaluate to true, the DeltaPositionY is not replaced that frame.

ConfigureDeltaScaleModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaScaleModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaScaleModifiers(IIterable<CompositionConditionalValue>) ConfigureDeltaScaleModifiers(IIterable<CompositionConditionalValue>)

Takes an ordered list of CompositionConditionalValue. In a frame, the first CompositionConditionalValue to have its “.Condition” evaluate to true replaces the DeltaScale value the VisualInteractionSource provides with its “.Value”. If none evaluate to true, the DeltaScale is not replaced that frame.

Create(Visual) Create(Visual) Create(Visual) Create(Visual)

Creates an instance of VisualInteractionSource.

PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo)

Defines a property that can be animated.

(Inherited from CompositionObject)
StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation)

Connects an animation with the specified property of the object and starts the animation.

(Inherited from CompositionObject)
StartAnimationGroup(ICompositionAnimationBase) StartAnimationGroup(ICompositionAnimationBase) StartAnimationGroup(ICompositionAnimationBase) StartAnimationGroup(ICompositionAnimationBase)

Starts an animation group.

The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup. All the animations in the group will be started at the same time on the object.

(Inherited from CompositionObject)
StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase)

Starts an animation group on the specified target.

(Inherited from CompositionObject)
StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation)

Connects an animation with the specified property of the target object and starts the animation.

(Inherited from CompositionObject)
StopAnimation(String) StopAnimation(String) StopAnimation(String) StopAnimation(String)

Disconnects an animation from the specified property and stops the animation.

(Inherited from CompositionObject)
StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase)

Stops an animation group.

(Inherited from CompositionObject)
TryGetAnimationController(String) TryGetAnimationController(String) TryGetAnimationController(String) TryGetAnimationController(String)

Returns an AnimationController for the animation running on the specified property.

(Inherited from CompositionObject)
TryRedirectForManipulation(PointerPoint) TryRedirectForManipulation(PointerPoint) TryRedirectForManipulation(PointerPoint) TryRedirectForManipulation(PointerPoint)

Indicates that configured manipulations for the given pointer stream should be sent to the InteractionTracker, not the app's UI thread, starting at the given PointerPoint.

TryRedirectForManipulation enables the VisualInteractionSource to redirect the Pointer stream to the InteractionTracker if the gesture matches the configuration on the VisualInteractionSource. This method should only be called with Pointer input of the DeviceType Touch.

See Also