TransferTarget Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- 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 |
| Id |
The |
| IsEnabled |
The |
| Label |
The |
Methods
| Name | Description |
|---|---|
| CreateWatcher(TransferTargetDiscoveryOptions) |
The |