Share via


TransferTarget Class

Definition

The TransferTarget class represents an application target for sharing data. It provides properties and methods to interact with and invoke the target for data transfer operations.

public ref class TransferTarget sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 1245184)]
/// [Windows.Foundation.Metadata.Experimental]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class TransferTarget final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 1245184)]
[Windows.Foundation.Metadata.Experimental]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class TransferTarget
Public NotInheritable Class TransferTarget
Inheritance
Object Platform::Object IInspectable TransferTarget
Attributes

Windows requirements

Requirements Description
Device family
Windows 11, version 24H2 (introduced in 10.0.26100.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v19.0)

Examples

For a complete sample demonstrating the use of the TransferTargetWatcher and related APIs, refer to the Transfer Target Watcher Sample.

Example - Discovering and Invoking a Transfer Target

var watcher = TransferTarget.CreateWatcher();
TransferTarget discoveredTarget = null;

watcher.Added += (sender, args) =>
{
    Console.WriteLine($"Target added: {args.Target.Label}");
    discoveredTarget = args.Target;
};
watcher.Start();

// Invoke a target with the parent window handle
if (discoveredTarget != null)
{
    var parentWindowId = Windows.UI.WindowId.CreateFromWindowHandle(hwnd);
    var result = await discoveredTarget.TransferToAsync(discoveredTarget, parentWindowId);
}

Remarks

The TransferTarget class is part of the Transfer Target Platform API, which is designed to streamline the process of discovering and invoking transfer targets asynchronously. This API supports multiple providers and includes comprehensive filter options to ensure relevant targets are discovered efficiently.

Key Features

  • Asynchronous Target Discovery: Ensures a responsive user experience by discovering targets asynchronously.
  • Invocation Support: Allows invoking transfer targets with a data package for seamless sharing.
  • Real-Time Updates: Provides events to notify applications about changes in available transfer targets.

Properties

Name Description
DisplayIcon

The DisplayIcon property gets the icon associated with the transfer target. This icon is typically used to visually represent the target in the user interface.

Id

The Id property gets the unique identifier of the transfer target. This identifier can be used to distinguish the target from others.

IsEnabled

The IsEnabled property indicates whether the transfer target is currently enabled and available for use.

Label

The Label property gets the display name of the transfer target. You typically show this name to users so they can identify the target.

Methods

Name Description
CreateWatcher(TransferTargetDiscoveryOptions)

The CreateWatcher method creates a new instance of the TransferTargetWatcher class, configured with the specified discovery options. This method allows applications to customize the discovery process for transfer targets.

Applies to

See also