-api-id | -api-type |
---|---|
T:Windows.ApplicationModel.DataTransfer.DataPackage |
winrt class |
Contains the data that a user wants to exchange with another app.
During a share operation, the source app puts the data being shared in a DataPackage object and sends that object to the target app for processing. The DataPackage class includes a number of methods to support the following default formats: text, Rtf, Html, Bitmap, and StorageItems. It also has methods to support custom data formats. To use these formats, both the source app and target app must already be aware that the custom format exists.
Source apps have the option of using SetDataProvider to assign a delegate to a DataPackage, instead of providing the data immediately. This process is useful when the source app supports a given format but does not want to generate the data unless the target app requests the data. For example, a source app might support a variety of image formats for sharing photos. Instead of creating multiple copies of each image using these formats, the source app can use a delegate that is called when the target app requests a specific format type.
Target apps can use the DataPackageView object to acquire the data being shared. In addition, these apps can use the AvailableFormats property to identify which formats the DataPackageView supports, or use the Contains method to query for a specific format.
This API is supported in native apps only.
Windows version | SDK version | Value added |
---|---|---|
1703 | 15063 | ShareCompleted |
2004 | 19041 | ShareCanceled |
[!code-csharpHowToShareTextBasic]
Clipboard sample (Windows 10), Sharing content source app sample (Windows 10) soft.com/fwlink/p/?LinkId=620596)