public static void Source(this Windows.ApplicationModel.DataTransfer.DataPackage dataPackage, IMimeItemCollection mimeItemCollection) { dataPackage.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy; var properties = dataPackage.Properties; if (mimeItemCollection.Description != null) { properties.Description = mimeItemCollection.Description ?? Forms9Patch.ApplicationInfoService.Name; } properties.ApplicationName = Forms9Patch.ApplicationInfoService.Name; properties.Title = mimeItemCollection.Description ?? "Share " + Forms9Patch.ApplicationInfoService.Name + " data ..."; var storageItems = new List <IStorageItem>(); var textSet = false; var htmlSet = false; var rtfSet = false; var uriSet = false; //var htmlItems = mimeItemCollection.GetMimeItems<string>("text/html"); foreach (var item in mimeItemCollection.Items) { var mimeType = item.MimeType.ToLower(); if (mimeType == "text/plain" && !textSet && item.AsString() is string text) { dataPackage.SetText(text); textSet = true; } // else if (mimeType == "text/html" && !htmlSet && item.AsString() is string html) else if (mimeType == "text/html" && !htmlSet && item.AsWindowsHtmlFragment() is string html) { dataPackage.SetHtmlFormat(html); htmlSet = true; } else if ((mimeType == "text/rtf" || mimeType == "text/richtext" || mimeType == "application/rtf" || mimeType == "application/x-rtf") && !rtfSet && item.AsString() is string rtf) { dataPackage.SetRtf(rtf); rtfSet = true; } else if (item.Value is Uri uri && !uriSet && uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { dataPackage.SetWebLink(uri); uriSet = true; } if (item.ToStorageFile() is StorageFile storageFile) { storageItems.Add(storageFile); } else { properties.Add(GetFormatId(item.MimeType), item.Value); } } if (storageItems.Count > 0) { dataPackage.SetStorageItems(storageItems); } }