Condividi tramite


DataTransferManager.GetForCurrentView Metodo

Definizione

Restituisce l'oggetto DataTransferManager associato alla finestra corrente.

public:
 static DataTransferManager ^ GetForCurrentView();
 static DataTransferManager GetForCurrentView();
public static DataTransferManager GetForCurrentView();
function getForCurrentView()
Public Shared Function GetForCurrentView () As DataTransferManager

Restituisce

Oggetto DataTransferManager associato alla finestra corrente.

Esempio

Questo esempio chiama il metodo GetForCurrentView per ottenere l'oggetto DataTransferManager associato alla finestra attiva per l'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!");
}

Commenti

A ogni finestra è associato un oggetto DataTransferManager . Quando si condivide il contenuto, utilizzare il metodo GetForCurrentView per ottenere l'oggetto DataTransferManager associato alla finestra attiva. Dopo aver ottenuto l'oggetto DataTransferManager appropriato, è possibile aggiungervi un listener di eventi per gestire l'evento DataRequested , generato dal sistema quando viene avviata un'operazione di condivisione. L'app usa l'oggetto DataRequest restituito con questo evento per impostare i dati che l'utente vuole condividere con un'app di destinazione.

Si applica a