DataRequest.Data Property

Definition

Sets or gets a DataPackage object that contains the content a user wants to share.

public:
 property DataPackage ^ Data { DataPackage ^ get(); void set(DataPackage ^ value); };
DataPackage Data();

void Data(DataPackage value);
public DataPackage Data { get; set; }
var dataPackage = dataRequest.data;
dataRequest.data = dataPackage;
Public Property Data As DataPackage

Property Value

Contains the content a user wants to share.

Examples

The following code shows how to get a DataPackage object from the Data property as part of setting the data on a DataPackage to share with another app.

//To see this code in action, add a call to ShareSourceLoad to your constructor or other
//initializing function.
private void ShareSourceLoad()
{
    DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
    dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);
}

private void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequest request = e.Request;
    request.Data.Properties.Title = "Share Text Example";
    request.Data.Properties.Description = "An example of how to share text.";
    request.Data.SetText("Hello World!");
}

Remarks

The Data property enables your app to supply data to a target app. Your app must supply this data by using a DataPackage object.

Use this property when your app has the content immediately available that the user wants to share. If you need to call a function to generate the DataPackage, use the GetDeferral method.

When your app cannot supply a DataPackage object, use the FailWithDisplayText method to cancel the share and provide a message that the target app can display to the user.

Applies to