本文整理匯總了C#中Windows.ApplicationModel.DataTransfer.DataPackage.SetDataProvider方法的典型用法代碼示例。如果您正苦於以下問題:C# DataPackage.SetDataProvider方法的具體用法?C# DataPackage.SetDataProvider怎麽用?C# DataPackage.SetDataProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.ApplicationModel.DataTransfer.DataPackage
的用法示例。
在下文中一共展示了DataPackage.SetDataProvider方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CopyBitmap
async private void CopyBitmap(bool isDelayRendered)
{
var imagePicker = new FileOpenPicker
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.PicturesLibrary,
FileTypeFilter = { ".jpg", ".png", ".bmp", ".gif", ".tif" }
};
var imageFile = await imagePicker.PickSingleFileAsync();
if (imageFile != null)
{
var dataPackage = new DataPackage();
// Use one click handler for two operations: regular copy and copy using delayed rendering
// Differentiate the case by the button name
if (isDelayRendered)
{
dataPackage.SetDataProvider(StandardDataFormats.Bitmap, request => OnDeferredImageRequestedHandler(request, imageFile));
OutputText.Text = "Image has been copied using delayed rendering";
}
else
{
dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile));
OutputText.Text = "Image has been copied";
}
try
{
Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
}
catch (Exception ex)
{
// Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
}
}
else
{
OutputText.Text = "No image was selected.";
}
}