Programmatically initiates an exchange of content with other apps.
The DataTransferManager class is a static class that you use to initiate sharing operations. To use the class, first call the GetForCurrentView method. This method returns the DataTransferManager object that is specific to the active window. Next, you need to add an event listener for the datarequested event to the object. This event is fired when your app starts a share operation programmatically.

The DataTransferManager class includes a ShowShareUI method, which you can use to programmatically start a share operation. In general, we recommend against using this method. Users expect to initiate share operations by using the Share charm—when you launch the operation programmatically, you can create an inconsistent user experience. We include the method because there are a few scenarios in which the user might not recognize opportunities to share. A good example is when the user achieves a high score in a game.

The DataTransferManager class also has a TargetApplicationChosen event. Use this event when you want to capture what applications a user selects when sharing content from your app.

Ejemplo n.º 1
0
        /// <summary>
        /// Returns the <see cref="DataTransferManager"/> object associated with the current window.
        /// </summary>
        /// <returns>The <see cref="DataTransferManager"/> object associated with the current window.</returns>
        public static DataTransferManager GetForCurrentView()
        {
            if (instance == null)
            {
                instance = new DataTransferManager();
            }

            return instance;
        }
Ejemplo n.º 2
0
 private void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
 {
     args.Request.Data.SetText("Hello world");
 }