/// <summary> /// Raised when the user initiates a Share operation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> async void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { DataRequest request = args.Request; // We are going to use an async API to talk to the webview, so get a deferral to give // us time to generate the results. DataRequestDeferral deferral = request.GetDeferral(); DataPackage dp = await Vista.CaptureSelectedContentToDataPackageAsync(); // Determine whether there was any selected content. bool hasSelection = false; try { hasSelection = (dp != null) && (dp.GetView().AvailableFormats.Count > 0); } catch (Exception ex) { switch (ex.HResult) { case unchecked ((int)0x80070490): // Mobile does not generate a data package with AvailableFormats // and results in an exception. Sorry. Handle the case by acting as // if we had no selected content. hasSelection = false; break; default: // All other exceptions are unexpected. Let them propagate. throw; } } if (hasSelection) { // Webview has a selection, so we'll share its data package. dp.Properties.Title = "Echa un vistazo a este artículo en PC Componentes:"; } else { // No selection, so we'll share the url of the webview. dp = new DataPackage(); dp.SetWebLink(Vista.Source); dp.Properties.Title = "Echa un vistazo a este artículo en PC Componentes:"; } dp.Properties.Description = Vista.Source.ToString(); request.Data = dp; deferral.Complete(); }