/// <summary> /// Invoked when user clicks filename, which downloads attachment file and open. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void lblFileName_Tapped(object sender, TappedRoutedEventArgs e) { // Get note item from sender StackPanel sp = (sender as TextBlock).Parent as StackPanel; Annotation note = sp.DataContext as Annotation; // I may need to cache and try to get from cache for attachment as some are big. // At least i can let users decide if they want to download or not. // Show download message. var result = await Util.ShowConfirmMessage(loader.GetString("ConfirmDownloadAttachment"), loader.GetString("Yes"), loader.GetString("No"), 0); // If user doesn't want to download it, then do nothing. if (!result) { return; } progressRing.IsActive = true; // Delete temporary data first await DeleteTemporaryData(); // Then obtain attachment noteAttachment = await CRMHelper.RetrieveNoteAttachment((Guid)note.AnnotationId); progressRing.IsActive = false; // Show confirm message result = await Util.ShowConfirmMessage(loader.GetString("ConfirmOpenSave"), loader.GetString("Open"), loader.GetString("Save"), 0); // if user just want to open it, then open it. if (result) { await Launcher.LaunchFileAsync(noteAttachment); } else { // Save to any location. var picker = new FileSavePicker(); #if WINDOWS_PHONE_APP picker.SuggestedFileName = noteAttachment.Name; picker.FileTypeChoices.Add(noteAttachment.DisplayType.ToString(), new List <string> { noteAttachment.FileType.ToString() }); picker.SuggestedSaveFile = noteAttachment; picker.PickSaveFileAndContinue(); #endif } }