protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (!this._isInitialized) { this._maxAllowedToSelect = int.Parse(((Page)this).NavigationContext.QueryString["MaxAllowedToSelect"]); long loggedInUserId = AppGlobalStateManager.Current.LoggedInUserId; DocumentsViewModel parentPageViewModel = new DocumentsViewModel(loggedInUserId); DocumentsSectionViewModel sectionViewModel = new DocumentsSectionViewModel(parentPageViewModel, loggedInUserId, 0, CommonResources.AllDocuments, false, true) { IsSelected = true }; parentPageViewModel.Sections.Add(sectionViewModel); parentPageViewModel.LoadSection(0); base.DataContext = parentPageViewModel; this._isInitialized = true; } if (e.NavigationMode != NavigationMode.Back || !ParametersRepository.Contains("FilePicked") && !ParametersRepository.Contains("PickedPhotoDocuments")) { return; } this.SkipNextNavigationParametersRepositoryClearing = true; Navigator.Current.GoBack(); }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (!this._isInitialized) { long ownerId = 0; bool isOwnerCommunityAdmined = false; if (((Page)this).NavigationContext.QueryString.ContainsKey("OwnerId")) { ownerId = long.Parse(((Page)this).NavigationContext.QueryString["OwnerId"]); } if (((Page)this).NavigationContext.QueryString.ContainsKey("IsOwnerCommunityAdmined")) { isOwnerCommunityAdmined = bool.Parse(((Page)this).NavigationContext.QueryString["IsOwnerCommunityAdmined"]); } if (ownerId != AppGlobalStateManager.Current.LoggedInUserId && !isOwnerCommunityAdmined) { this.ApplicationBar.Buttons.Remove(this._appBarAddButton); } DocumentsViewModel parentPageViewModel = new DocumentsViewModel(ownerId); parentPageViewModel.Sections.Add(new DocumentsSectionViewModel(parentPageViewModel, ownerId, 0, CommonResources.Header_ShowAll, isOwnerCommunityAdmined, false)); parentPageViewModel.LoadSection(0); ((FrameworkElement)this).DataContext = parentPageViewModel; this._isInitialized = true; } else if (ParametersRepository.Contains("FilePicked")) { FileOpenPickerContinuationEventArgs parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; StorageFile m0; if (parameterForIdAndReset == null) { m0 = null; } else { IReadOnlyList <StorageFile> files = parameterForIdAndReset.Files; m0 = files != null?Enumerable.FirstOrDefault <StorageFile>(files) : null; } StorageFile storageFile = (StorageFile)m0; if (storageFile == null) { return; } this.ViewModel.UploadDocuments(new List <StorageFile>() { storageFile }); } else { if (!ParametersRepository.Contains("PickedPhotoDocuments")) { return; } List <StorageFile> parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments") as List <StorageFile>; if (parameterForIdAndReset == null || !Enumerable.Any <StorageFile>(parameterForIdAndReset)) { return; } this.ViewModel.UploadDocuments(parameterForIdAndReset); } }