private void Button_Click(object sender, RoutedEventArgs e) { var dlg = new CommonOpenFileDialog(); dlg.Title = "My Title"; dlg.IsFolderPicker = true; dlg.AddToMostRecentlyUsedList = false; dlg.AllowNonFileSystemItems = false; dlg.EnsureFileExists = true; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.Multiselect = false; dlg.ShowPlacesList = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { path_from_dialog = dlg.FileName; } var is_repeated = false; foreach (var item in PathNames) { if (item.Name == path_from_dialog) { is_repeated = true; break; } } if (path_from_dialog != "" && !is_repeated) { PathNames.Push(new PathInfo(path_from_dialog)); } is_repeated = false; Serialize(); Deserialize(); PathBox.ItemsSource = PathNames; Text.Text = path_from_dialog; try { var mainMetroWindow = new MainMetroWindow(); var viewModel = new MainMetroWindowViewModel(path_from_dialog); mainMetroWindow.DataContext = viewModel; ViewModel = viewModel; mainMetroWindow.Show(); Close(); } catch { } }
private void Button_Click_1(object sender, RoutedEventArgs e) { var path = PathBox.SelectedItem as PathInfo; if (path.Name != "") { var p = path.Name; var mainMetroWindow = new MainMetroWindow(); var viewModel = new MainMetroWindowViewModel(p); ViewModel = viewModel; mainMetroWindow.DataContext = viewModel; mainMetroWindow.Show(); Close(); } }