private static async void OnPdfPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { PdfViewerControl control = source as PdfViewerControl; var pdfSource = e.NewValue as String; if (string.IsNullOrEmpty(pdfSource)) { return; } try { if (control != null) { control.ClearSource(); var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(pdfSource)); await ShowProgressIndicatorIfNecessary(control, file); control.LoadPDF(file); } } catch { // TODO Log exception here } }
private static async Task ShowProgressIndicatorIfNecessary(PdfViewerControl control, StorageFile file) { var size = await file.GetSize(); var sizeInMB = size / 1048576.0; if (sizeInMB > ProgressIndicationFileSizeLimitInMB) { control.IsLoading = true; control.IsPdfError = false; } }