Skip to content

Instantly share code, notes, and snippets.

@MartinZikmund
Created September 1, 2020 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinZikmund/6a9b3d0d3fdd242b6bcb5cb97c70d888 to your computer and use it in GitHub Desktop.
Save MartinZikmund/6a9b3d0d3fdd242b6bcb5cb97c70d888 to your computer and use it in GitHub Desktop.
var view = item.Content;
if (view.Contains(StandardDataFormats.Bitmap))
{
var bitmapReference = await view.GetBitmapAsync();
if (bitmapReference != null)
{
var bitmap = new BitmapImage();
await bitmap.SetSourceAsync(await bitmapReference.OpenReadAsync());
viewer.ContentGrid.Children.Add(new Image() { Width = 300, Height = 300, Stretch = Stretch.None, Source = bitmap });
}
}
else if (view.Contains(StandardDataFormats.Text))
{
var text = await view.GetTextAsync();
if (text != null)
{
viewer.ContentGrid.Children.Add(new TextBlock() { Text = text });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment