private void RegisterFileOpenPicker() { var view = CoreApplication.GetCurrentView(); _fileOpenPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.PicturesLibrary }; _fileOpenPicker.FileTypeFilter.Add(".jpg"); _fileOpenPicker.FileTypeFilter.Add(".jpeg"); _fileOpenPicker.FileTypeFilter.Add(".png"); view.Activated += async(applicationView, args) => { var fileOpenPickerArgs = args as FileOpenPickerContinuationEventArgs; if (fileOpenPickerArgs != null && fileOpenPickerArgs.Files.Count > 0) { var selectedImageFile = fileOpenPickerArgs.Files[0]; await _ocrHelper.ProcessImage(selectedImageFile, OcrLanguage.SelectedItem.ToString()); } }; }
private async void Button_Click(object sender, RoutedEventArgs e) { var view = CoreApplication.GetCurrentView(); var fileOpenPicker = new FileOpenPicker(); fileOpenPicker.ViewMode = PickerViewMode.Thumbnail; fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.FileTypeFilter.Add(".jpeg"); fileOpenPicker.FileTypeFilter.Add(".png"); var selectedImageFile = await fileOpenPicker.PickSingleFileAsync(); await _ocrHelper.ProcessImage(selectedImageFile, OcrLanguage.SelectedItem.ToString()); }