Share via


CompositionInteractionSourceCollection Class

Definition

A collection of interaction sources.

This is the collection of interaction sources that are associated with a given InteractionTracker. The only valid member of this collection is a VisualInteractionSource. Each VisualInteractionSource needs to have a unique hit-test (source) visual. Each VisualInteractionSource will be configured individually for the desired input to be sent to the InteractionTracker.

public ref class CompositionInteractionSourceCollection sealed : CompositionObject, IIterable<ICompositionInteractionSource ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CompositionInteractionSourceCollection final : CompositionObject, IIterable<ICompositionInteractionSource>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionInteractionSourceCollection : CompositionObject, IEnumerable<ICompositionInteractionSource>
Public NotInheritable Class CompositionInteractionSourceCollection
Inherits CompositionObject
Implements IEnumerable(Of ICompositionInteractionSource)
Inheritance
Object Platform::Object IInspectable CompositionObject CompositionInteractionSourceCollection
Attributes
Implements

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Examples

void SetupMultipleSourceInteractionTracker(Visual horizontalVisual, Visual verticalVisual, Visual contentVisual)
{
  //
  // Create the InteractionTracker and set its min/max position.  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);


  //
  // Configure the two interaction sources.  Enable input with inertia.  
  //

  var interactionSource1 = VisualInteractionSource.Create(horizontalVisual);
  var interactionSource2 = VisualInteractionSource.Create(verticalVisual);

  interactionSource1.PositionXSourceMode = 
  InteractionSourceMode.EnabledWithInertia; 

  interactionSource2.PositionYSourceMode = 
  InteractionSourceMode.EnabledWithInertia;


  _tracker.InteractionSources.Add(interactionSource1);
  _tracker.InteractionSources.Add(interactionSource2);


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

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

  contentVisual.StartAnimation("Offset", positionExpression);
}

Remarks

While multiple CompositionInteractionSources can be added to the same CompositionInteractionSourceCollection the most common case is to only have one member in this collection. Multiple can be used if multiple hit-test regions should drive the same InteractionTracker. If multiple source visuals are hit-test at the same time the visual tree hierarchy will determine which one takes precedence. If any common parent contains more hit-test contacts than a single child, the input will be promoted to that parent.

Properties

Comment

A string to associate with the CompositionObject.

(Inherited from CompositionObject)
Compositor

The Compositor used to create this CompositionObject.

(Inherited from CompositionObject)
Count

The number of interaction sources in the collection.

Dispatcher

The dispatcher for the CompositionObject.

(Inherited from CompositionObject)
DispatcherQueue

Gets the DispatcherQueue for the CompostionObject.

(Inherited from CompositionObject)
ImplicitAnimations

The collection of implicit animations attached to this object.

(Inherited from CompositionObject)
Properties

The collection of properties associated with the CompositionObject.

(Inherited from CompositionObject)

Methods

Add(ICompositionInteractionSource)

Adds an interaction source to the collection.

Close()

Closes the CompositionObject and releases system resources.

(Inherited from CompositionObject)
ConnectAnimation(String, CompositionAnimation)

Connects and animation.

(Inherited from CompositionObject)
DisconnectAnimation(String)

Disconnects an animation.

(Inherited from CompositionObject)
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from CompositionObject)
First()

Returns an iterator pointing to the first object in the collection.

PopulatePropertyInfo(String, AnimationPropertyInfo)

Defines a property that can be animated.

(Inherited from CompositionObject)
Remove(ICompositionInteractionSource)

Removes the specified interaction source from the collection.

RemoveAll()

Removes all interaction sources from the collection.

StartAnimation(String, CompositionAnimation, AnimationController)

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

(Inherited from CompositionObject)
StartAnimation(String, CompositionAnimation)

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

(Inherited from CompositionObject)
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)
StopAnimation(String)

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

(Inherited from CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

Stops an animation group.

(Inherited from CompositionObject)
TryGetAnimationController(String)

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

(Inherited from CompositionObject)

Applies to

See also