-api-id | -api-type |
---|---|
M:Windows.ApplicationModel.DataTransfer.DataPackage.SetDataProvider(System.String,Windows.ApplicationModel.DataTransfer.DataProviderHandler) |
winrt method |
Sets a delegate to handle requests from the target app.
Specifies the format of the data. We recommend that you set this value by using the StandardDataFormats class.
A delegate that is responsible for processing requests from a target app.
Use the SetDataProvider method when your app supports a specific format, but does not want to supply the data until the target app requests it. We encourage you to use this method if your app shares content that can require significant processing time; for example, sharing a selection of photos, videos, or files.
When you use this method, you need to specify a format and a function. You can specify the format by using the StandardDataFormats class, or you can use a string value for a custom format. The function must put data in the DataPackage by using a method like SetData.
You must specify the extension of the StorageItems being passed to the Share Target.
The SetDataProvider method is different from the GetDeferral method of the DataRequest class. With GetDeferral, a source app can call a function that immediately puts the data in the DataPackage object. The SetDataProvider method is for more complex share operations where packaging the data to be shared is more time-intensive or resource-intensive.
[!code-csharpHowToShareFiles]