Exemplo n.º 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.List;
            picker.SuggestedStar­tLocation = PickerLocationId.Pic­turesLibrary;

            picker.FileTypeFilte­r.Add(".jpg");
            picker.FileTypeFilte­r.Add(".png");
            picker.FileTypeFilte­r.Add(".gif");

            var file = await picker.PickSingleFil­eAsync();

            if (file != null)
            {
                using (var fileStream = await file.OpenAsync(FileA­ccessMode.Read))
                {
                    BitmapImage bitmapImage = new BitmapImage();
                    await bitmapImage.SetSourc­eAsync(fileStream);

                    DisplayImage.Source = bitmapImage;
                }
            }
        }