private void AddRecentFolder_Executed(object p) { string path; IListControllerViewModel vm; this.ResolveParameterList(p as List <object>, out path, out vm); if (vm == null) { return; } var browser = FolderBrowserFactory.CreateBrowserViewModel(); path = (string.IsNullOrEmpty(path) == true ? PathFactory.SysDefault.Path : path); browser.InitialPath = path; var dlg = new FolderBrowser.Views.FolderBrowserDialog(); var dlgViewModel = FolderBrowserFactory.CreateDialogViewModel( browser, vm.RecentFolders.CloneBookmark()); dlg.DataContext = dlgViewModel; bool?bResult = dlg.ShowDialog(); if (dlgViewModel.DialogCloseResult == true || bResult == true) { vm.CloneBookmarks(dlgViewModel.BookmarkedLocations, vm.RecentFolders); vm.AddRecentFolder(dlgViewModel.TreeBrowser.SelectedFolder, true); } }
/// <summary> /// Shows a sample progress dialog that was invoked via a bound viewmodel. /// </summary> /// <param name="context"></param> /// <param name="progressIsFinite"></param> internal async Task <string> ShowContentDialogFromVM( object context , bool progressIsFinite ) { // See Loaded event in FolderBrowserTreeView_Loaded method to understand initial load var treeBrowserVM = FolderBrowserFactory.CreateBrowserViewModel(_SpecialFolderVisibility , _InitialPath); // Switch updates to view of by default to speed up load of view // Loading the view will kick-off the browsing via View.Loaded Event // and that in turn will switch on view updates ... treeBrowserVM.UpdateView = false; var fsDlg = FolderBrowserFactory.CreateDialogViewModel(treeBrowserVM, BookmarkedLocations); var customDialog = CreateFolderBrowserDialog(new FolderBrowserContentDialogViewModel(fsDlg)); var coord = GetService <IContentDialogService>().Coordinator; var manager = GetService <IContentDialogService>().Manager; string returnPath = null; // Show a progress dialog to initialize the viewmodel - in case file system is slow... await coord.ShowMetroDialogAsync(context, customDialog).ContinueWith ( (t) => { if (t.Result == DialogIntResults.OK) { returnPath = treeBrowserVM.SelectedFolder; } } ); if (fsDlg.BookmarkedLocations != null) { this.BookmarkedLocations = fsDlg.BookmarkedLocations.CloneBookmark(); } return(returnPath); }