private void NewTemplateButton_Click(object sender, RoutedEventArgs e) { using (var dlg = new CommonSaveFileDialog()) { dlg.Title = "Create new template file"; dlg.InitialDirectory = (string)TemplatesDirSelection.SelectedItem; dlg.AddToMostRecentlyUsedList = false; dlg.DefaultDirectory = TemplateFactory.GetInstance().TemplatesDirectory; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.ShowPlacesList = true; dlg.DefaultExtension = ".json"; dlg.Filters.Add(new CommonFileDialogFilter("json", ".json")); if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { string path = dlg.FileName; TemplateFactory.GetInstance().CreateNewTemplate(path); SelectedTemplate = path; FilesList.Focus(); } } }