Skip to content

Commit afd1cf4

Browse files
committed
Update TransferTarget from review
1 parent 7e2b32d commit afd1cf4

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

windows.applicationmodel.datatransfer/transfertarget.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
public sealed class TransferTarget
1010
-->
1111

12-
1312
## -description
1413

15-
The `TransferTarget` class represents a target for sharing data, such as an application or device. It provides properties and methods to interact with and invoke the target for data transfer operations.
14+
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.
1615

1716
## -remarks
1817

1918
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.
2019

21-
#### Key Features:
20+
#### Key Features
2221

2322
- **Asynchronous Target Discovery**: Ensures a responsive user experience by discovering targets asynchronously.
2423
- **Invocation Support**: Allows invoking transfer targets with a data package for seamless sharing.
@@ -30,18 +29,23 @@ The `TransferTarget` class is part of the Transfer Target Platform API, which is
3029

3130
## -examples
3231

33-
#### Example: Discovering and Invoking a Transfer Target
32+
#### Example - Discovering and Invoking a Transfer Target
3433

3534
```csharp
3635
var watcher = TransferTarget.CreateWatcher();
36+
TransferTarget discoveredTarget = null;
37+
3738
watcher.Added += (sender, args) =>
3839
{
3940
Console.WriteLine($"Target added: {args.Target.Label}");
41+
discoveredTarget = args.Target;
4042
};
4143
watcher.Start();
4244

43-
// Invoke a target with a data package
44-
var dataPackage = new DataPackage();
45-
dataPackage.SetText("Hello, World!");
46-
await watcher.TransferToAsync(target, dataPackage);
45+
// Invoke a target with the parent window handle
46+
if (discoveredTarget != null)
47+
{
48+
var parentWindowId = Windows.UI.WindowId.CreateFromWindowHandle(hwnd);
49+
var result = await discoveredTarget.TransferToAsync(discoveredTarget, parentWindowId);
50+
}
4751
```

0 commit comments

Comments
 (0)