Created
January 21, 2018 00:40
-
-
Save jcotton42/76c65f8a29e0a4d4b1bc2bc799d0a975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
x:Class="UWPTest.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:UWPTest" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
mc:Ignorable="d"> | |
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Orientation="Vertical"> | |
<Button Content="Browse.." Click="Button_Click"/> | |
<Image x:Name="Img" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/> | |
</StackPanel> | |
</Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Windows.Storage.Pickers; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Media.Imaging; | |
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 | |
namespace UWPTest { | |
/// <summary> | |
/// An empty page that can be used on its own or navigated to within a Frame. | |
/// </summary> | |
public sealed partial class MainPage : Page | |
{ | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
} | |
private async void Button_Click(object sender, RoutedEventArgs e) { | |
var picker = new FileOpenPicker() { | |
ViewMode = PickerViewMode.Thumbnail, | |
SuggestedStartLocation = PickerLocationId.PicturesLibrary | |
}; | |
picker.FileTypeFilter.Add(".png"); | |
picker.FileTypeFilter.Add(".jpg"); | |
var file = await picker.PickSingleFileAsync(); | |
var image = new BitmapImage(); | |
await image.SetSourceAsync(await file.OpenReadAsync()); | |
Img.Source = image; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment