Visual​Interaction​Source Visual​Interaction​Source Visual​Interaction​Source 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, IVisualInteractionSource2public class VisualInteractionSource : CompositionObject, ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2Public Class VisualInteractionSource Inherits CompositionObject Implements ICompositionInteractionSource, IVisualInteractionSource, IVisualInteractionSource2
Inheritance
VisualInteractionSourceVisualInteractionSourceVisualInteractionSource
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Inherited Members

Inherited methods

Inherited properties

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

DeltaPosition DeltaPosition DeltaPosition

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

public : Vector3 DeltaPosition { get; }public Vector3 DeltaPosition { get; }Public ReadOnly Property DeltaPosition As Vector3
Value
Vector3 Vector3 Vector3

The change in position of the interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

DeltaScale DeltaScale DeltaScale

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

public : float DeltaScale { get; }public float DeltaScale { get; }Public ReadOnly Property DeltaScale As float
Value
float float float

The change in scale of the visual interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : PlatForm::Boolean IsPositionXRailsEnabled { get; set; }public bool IsPositionXRailsEnabled { get; set; }Public ReadWrite Property IsPositionXRailsEnabled As bool
Value
PlatForm::Boolean bool bool

Boolean value indicating whether panning on the x-axis is railed.

Attributes

Examples


void SetupInteractionSource(ContainerVisual container, InteractionTracker   tracker)
{
  // Setup the InteractionSource
  _interactionSource = VisualInteractionSource.Create(container);
  // Enable the property for rails on the X axis being enabled
  _interactionSource.IsPositionXRailsEnabled = true;
  // Add the InteractionSource to the InteractionTracker
  tracker.InteractionSources.Add(_interactionSource);
}

Remarks

When this property is enabled, the system provides more leniency in what is considered a “perfect” horizontal pan. Often times when a finger pans across the screen, it is very difficult for an end user to achieve a perfect pan in the X-direction. This property helps makes it more possible to have “perfect” horizontal panning in scenarios (such as multi-directional scrolling) where both X and Y panning is already enabled.

When enabled, pans within 22.5 degrees of the horizontal axis will get recognized as “perfect” horizontal pans – in other words, their Y components will be ignored. Note that the angle of the pan is determined within the first few millimeters of the interaction and will retain that angle until the finger is lifted. If outside the threshold of 22.5 degrees of the axis, then the Y component will then be recognized.

The diagram below shows this in a visual format:

Pans within 22.5 degrees of the horizontal axis will get recognized as perfect horizontal pans – in other words, their Y components will be ignored. If outside the threshold of 22.5 degrees of the axis, then the Y component will then be recognized.

Note

When rails are enabled, this has an impact to chaining. The system will only chain up to its nearest acenstor VisualInteractionSource when the pan is within 22.5 degrees of the axis.

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.

public : PlatForm::Boolean IsPositionYRailsEnabled { get; set; }public bool IsPositionYRailsEnabled { get; set; }Public ReadWrite Property IsPositionYRailsEnabled As bool
Value
PlatForm::Boolean bool bool

Boolean value indicating whether panning on the y-axis is railed.

Attributes

Examples


void SetupInteractionSource(ContainerVisual container, InteractionTracker   tracker)
{
  // Setup the InteractionSource
  _interactionSource = VisualInteractionSource.Create(container);
  // Enable the property for rails on the Y axis being enabled
  _interactionSource.IsPositionYRailsEnabled = true;
  // Add the InteractionSource to the InteractionTracker
  tracker.InteractionSources.Add(_interactionSource);
}

Remarks

When this property is enabled, the system provides more leniency in what is considered a “perfect” vertical pan. Often times when a finger pans across the screen, it is very difficult for an end user to achieve a perfect pan in the Y-direction. This property helps makes it more possible to have “perfect” vertical panning in scenarios (such as multi-directional scrolling) where both X and Y panning is already enabled.

When enabled, pans within 22.5 degrees of the vertical axis will get recognized as “perfect” vertical pans – in other words, their X components will be ignored. Note that the angle of the pan is determined within the first few millimeters of the interaction and will retain that angle until the finger is lifted. If outside the threshold of 22.5 degrees of the axis, then the X component will then be recognized.

The diagram below shows this in a visual format:

Pans within 22.5 degrees of the vertical axis will get recognized as perfect vertical pans – in other words, their X components will be ignored. If outside the threshold of 22.5 degrees of the axis, then the X component will then be recognized.

Note

When rails are enabled, this has an impact to chaining. The system will only chain up to its nearest acenstor VisualInteractionSource when the pan is within 22.5 degrees of the axis.

ManipulationRedirectionMode ManipulationRedirectionMode ManipulationRedirectionMode

Indicates what input should be redirected to the InteractionTracker.

public : VisualInteractionSourceRedirectionMode ManipulationRedirectionMode { get; set; }public VisualInteractionSourceRedirectionMode ManipulationRedirectionMode { get; set; }Public ReadWrite Property ManipulationRedirectionMode As VisualInteractionSourceRedirectionMode
Value
VisualInteractionSourceRedirectionMode VisualInteractionSourceRedirectionMode VisualInteractionSourceRedirectionMode

Indicates what input should be redirected to the InteractionTracker.

Attributes

Position Position Position

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

public : Vector3 Position { get; }public Vector3 Position { get; }Public ReadOnly Property Position As Vector3
Value
Vector3 Vector3 Vector3

The position of the interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : Vector3 PositionVelocity { get; }public Vector3 PositionVelocity { get; }Public ReadOnly Property PositionVelocity As Vector3
Value
Vector3 Vector3 Vector3

The position velocity of the interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : InteractionChainingMode PositionXChainingMode { get; set; }public InteractionChainingMode PositionXChainingMode { get; set; }Public ReadWrite Property PositionXChainingMode As InteractionChainingMode
Attributes

Examples


void SetupInteractionSource(ContainerVisual container, InteractionTracker tracker)
{
  // Setup the Interaction Source
  _interactionSource = VisualInteractionSource.Create(container);
  // Disable chaining on the X component.
  _interactionSource.PositionXChainingMode = InteractionChainingMode.Never; 
  // Attach the VisualInteractionSource to InteractionTracker
  tracker.InteractionSources.Add(_interactionSource);
}

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.

public : InteractionSourceMode PositionXSourceMode { get; set; }public InteractionSourceMode PositionXSourceMode { get; set; }Public ReadWrite Property PositionXSourceMode As InteractionSourceMode
Attributes

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.

public : InteractionChainingMode PositionYChainingMode { get; set; }public InteractionChainingMode PositionYChainingMode { get; set; }Public ReadWrite Property PositionYChainingMode As InteractionChainingMode
Attributes

Examples


void SetupInteractionSource(ContainerVisual container, InteractionTracker   tracker)
{
  // Setup the Interaction Source
  _interactionSource = VisualInteractionSource.Create(container);
  // Enable chaining for the Y direction.
  _interactionSource.PositionYChainingMode = InteractionChainingMode.Always;
  // Attach the VisualInteractionSource to InteractionTracker
  tracker.InteractionSources.Add(_interactionSource);
}

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.

public : InteractionSourceMode PositionYSourceMode { get; set; }public InteractionSourceMode PositionYSourceMode { get; set; }Public ReadWrite Property PositionYSourceMode As InteractionSourceMode
Attributes

Scale Scale Scale

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

public : float Scale { get; }public float Scale { get; }Public ReadOnly Property Scale As float
Value
float float float

The scale of the interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : InteractionChainingMode ScaleChainingMode { get; set; }public InteractionChainingMode ScaleChainingMode { get; set; }Public ReadWrite Property ScaleChainingMode As InteractionChainingMode
Attributes

Examples


void SetupInteractionSource(ContainerVisual container, InteractionTracker   tracker)
{
  // Setup the Interaction Source
  _interactionSource = VisualInteractionSource.Create(container);
  // Auto chaining for Scale
  _interactionSource.ScaleChainingMode = InteractionChainingMode.Auto;    
  // Attach the VisualInteractionSource to InteractionTracker
  tracker.InteractionSources.Add(_interactionSource);
}

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.

public : InteractionSourceMode ScaleSourceMode { get; set; }public InteractionSourceMode ScaleSourceMode { get; set; }Public ReadWrite Property ScaleSourceMode As InteractionSourceMode
Value
InteractionSourceMode InteractionSourceMode InteractionSourceMode

Source mode for the scale axis.

Attributes

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.

public : float ScaleVelocity { get; }public float ScaleVelocity { get; }Public ReadOnly Property ScaleVelocity As float
Value
float float float

The scale velocity of the interaction source.

Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Source Source Source

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

public : Visual Source { get; }public Visual Source { get; }Public ReadOnly Property Source As Visual
Value
Visual Visual Visual

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

Attributes

Methods

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.

public : void ConfigureCenterPointXModifiers(IIterable<CompositionConditionalValue> conditionalValues)public void ConfigureCenterPointXModifiers(IEnumerable<CompositionConditionalValue> conditionalValues)Public Function ConfigureCenterPointXModifiers(conditionalValues As IEnumerable<CompositionConditionalValue>) As void
Parameters
conditionalValues
IIterable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue>
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : void ConfigureCenterPointYModifiers(IIterable<CompositionConditionalValue> conditionalValues)public void ConfigureCenterPointYModifiers(IEnumerable<CompositionConditionalValue> conditionalValues)Public Function ConfigureCenterPointYModifiers(conditionalValues As IEnumerable<CompositionConditionalValue>) As void
Parameters
conditionalValues
IIterable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue>
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : void ConfigureDeltaPositionXModifiers(IIterable<CompositionConditionalValue> conditionalValues)public void ConfigureDeltaPositionXModifiers(IEnumerable<CompositionConditionalValue> conditionalValues)Public Function ConfigureDeltaPositionXModifiers(conditionalValues As IEnumerable<CompositionConditionalValue>) As void
Parameters
conditionalValues
IIterable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue>
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : void ConfigureDeltaPositionYModifiers(IIterable<CompositionConditionalValue> conditionalValues)public void ConfigureDeltaPositionYModifiers(IEnumerable<CompositionConditionalValue> conditionalValues)Public Function ConfigureDeltaPositionYModifiers(conditionalValues As IEnumerable<CompositionConditionalValue>) As void
Parameters
conditionalValues
IIterable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue>
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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.

public : void ConfigureDeltaScaleModifiers(IIterable<CompositionConditionalValue> conditionalValues)public void ConfigureDeltaScaleModifiers(IEnumerable<CompositionConditionalValue> conditionalValues)Public Function ConfigureDeltaScaleModifiers(conditionalValues As IEnumerable<CompositionConditionalValue>) As void
Parameters
conditionalValues
IIterable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue> IEnumerable<CompositionConditionalValue>
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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

Creates an instance of VisualInteractionSource.

public : static VisualInteractionSource Create(Visual source)public static VisualInteractionSource Create(Visual source)Public Static Function Create(source As Visual) As VisualInteractionSource
Parameters
source
Visual Visual Visual

The visual to use as the source of the interaction.

Returns
Attributes

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.

public : void TryRedirectForManipulation(PointerPoint pointerPoint)public void TryRedirectForManipulation(PointerPoint pointerPoint)Public Function TryRedirectForManipulation(pointerPoint As PointerPoint) As void
Parameters
pointerPoint
PointerPoint PointerPoint 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.

Attributes

Examples


///////////////////////////////////////////////////////////////////////////////////////////////
//
// The following sample describes how to configure a visual to follow input/gestures.  
//
// This is accomplished in three main steps:
//
// 1) Creating a InteractionTracker and setting (or binding) it's boundaries.
//
// 2) Creating at least one Interaction source and associating it with the InteractionTracker.
//
// 3) Taking the output of the InteractionTracker and applying it to a Visual's Offset and Scale 
//    properties.
//
// 4) Telling the system to try to handle the manipulation when the PointerPressed occurs
//
///////////////////////////////////////////////////////////////////////////////////////////////

void SetupSimpleInteractionTracker(Visual containerVisual, 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 - containerVisual.Size.X,
  contentVisual.Size.Y - containerVisual.Size.Y,
  0.0f);

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


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

  _interactionSource = VisualInteractionSource.Create(_compositor, containerVisual);

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

  _tracker.InteractionSources.Add(_interactionSource);

  //
  // Register for the pointer pressed event so that we can tell the system to handle the
  // manipulations.
  //

  _rootElement.PointerPressed += OnPointerPressedBasic;

  //
  // 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);
}

private void OnPointerPressedBasic(object sender, PointerRoutedEventArgs e)
{
  //
  // Try to handle the manipulation in the system.
  //
  if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
  {       
    _interactionSource.TryRedirectForManipulation(
    e.CurrentPoint.GetCurrentPoint(_rootElement));
  }
}

Compositor _compositor = null;
InteractionTracker _tracker = null;
UIElement _rootElement = null;
VisualInteractionSource _interactionSource;

Remarks

This method enables the app to indicates that the system (Compositor) should take over any configured manipulations for a given VisualInteractionSource. When TryRedirectForManipulation is called, the frame from the passed in PointerPoint is used as the starting point for the InteractionTracker ’s input handling. If the user’s gesture is hit-tested to the visual associated with the VisualInteractionSource (or one of its children), and the user performs a configured gesture, then the system will manipulate. If the input is hit-tested to another visual or the user performs a non-configured gesture then the input will be sent to the CoreWindow and through XAML’s normal input routing.

If the VisualInteractionSource reroutes the input stream to the InteractionTracker, the application will receive a PointerCaptureLost on the UIElement, or a PointerRoutedAway on the CoreWindow. These messages indicate that the input has been sent away from the application UI thread. This method will be most commonly called on PointerPressed.

PrecisionTouchpad input does not require this call and will be automatically routed to the InteractionTracker for the appropriate gestures if the InputRedirectionMode has been set to include CapableTouchpad input.

Limitations

Async Nature

The nature of this system is asynchronous. By the time the app calls TryRedirectForManipulation and the call reaches the compositor, there will be additional input events that could have made it to the application’s UI thread. In most cases, it is not harmful for the app to have received these events, and the developer can choose to gesture detect app side to determine how to handle the input and mitigate concerns. The app will know whether the system manipulation takes over by receiving a PointerCaptureLost—the same event received when ScrollViewer takes over input handling today. One complication here is that it is possible for a gesture like a “quick flick” (just a short pan) to send the entire input stream, including the PointerReleased, to the application before the compositor can respond. If the app is impacted by these limitations, they can opt to do some amount of gesture detection on their side to ensure the right behavior.

Integration with XAML Controls Logic

In the quick flick scenario described above where the pan happens to be on a control like a button, the button will detect the pan as a click if it is contained within the button. This is slightly different than how the system GestureRecognizer (which is doing the routing) detects gestures. In order to ensure quick flick type scenarios work correctly with XAML, developers will need to listen for OnTapped on the button rather than just Click if it is within a compositor interaction area.

Compositor Hit-testing

The hit-test result used for determining if the manipulation is happening on the right visual will be based on the compositor’s hit-testing. Compositor hit-testing is not as robust as XAML hit-testing, so there are cases where results could have a slight discrepancy.

See the VisualInteractionSource documentation for more details.

Integration With Conflicting Custom Gesture Recognizers

Internally, the system GestureRecognizer is being used to route input. Apps can generally get the behavior they want as long as they are using system gesture recognition. If an app is attempting to use a custom recognizer that conflicts with the system recognizer then there could be conflicts where the app expects the compositor to take over and it does not.

See Also