DataPackage.SetText(String) DataPackage.SetText(String) DataPackage.SetText(String) DataPackage.SetText(String) DataPackage.SetText(String) Method


Sets the text that a DataPackage contains.

public : void SetText(Platform::String value)
void SetText(winrt::hstring value) const;
public void SetText(String value)
Public Sub SetText(value As String)


String String String

The text.


//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!");
function registerForShare() {
    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
    dataTransferManager.addEventListener("datarequested", shareTextHandler);

function shareTextHandler(e) {
    var request = e.request; = "Share Text Example"; = "A demonstration that shows how to share.";"Hello World!");


This method sets the text value for StandardDataFormats.Text. It's the equivalent of calling dataPackage.setText(StandardDataFormats.Text).

Text is one of the data types that the DataPackage object supports directly. See the StandardDataFormats class for information on other supported data types.