/// <summary> /// Executes the ChooseFile command /// </summary> public void ChooseFile() { try { var options = new FileAndFolderDialog.Abstractions.SaveFileOptions() { AddExtension = this.AddExtension, CheckFileExists = this.CheckFileExists, CheckPathExists = this.CheckPathExists, DefaultExt = this.DefaultExt, DereferenceLinks = this.DereferenceLinks, Filter = this.Filter, FilterIndex = this.FilterIndex, InitialDirectory = this.InitialDirectory, CreatePrompt = this.CreatePrompt, OverwritePrompt = this.OverwritePrompt, RestoreDirectory = this.RestoreDirectory, Title = this.Title, ValidateNames = this.ValidateNames, DefaultFileName = this.DefaultFileName, }; this.CustomPlaces .ToList() .ForEach(p => options.CustomPlaces.Add(p)); var results = _fileDialogService.ShowSaveFileDialog(options); if (results == null || !results.Any()) { this.Results = null; } else { this.Results = string.Join(Environment.NewLine, results); } } catch (Exception ex) { this.Results = ex.Message; } }
} //design time only public SaveFileDialogExampleViewModel(FileAndFolderDialog.Abstractions.IFileDialogService fileDialogService) { this._fileDialogService = fileDialogService; //set defaults var options = new FileAndFolderDialog.Abstractions.SaveFileOptions(); this.AddExtension = options.AddExtension; this.CheckFileExists = options.CheckFileExists; this.CheckPathExists = options.CheckPathExists; this.DefaultExt = options.DefaultExt; this.DereferenceLinks = options.DereferenceLinks; this.Filter = options.Filter; this.FilterIndex = options.FilterIndex; this.InitialDirectory = options.InitialDirectory; this.OverwritePrompt = options.OverwritePrompt; this.RestoreDirectory = options.RestoreDirectory; this.CreatePrompt = options.CreatePrompt; this.Title = options.Title; this.ValidateNames = options.ValidateNames; this.DefaultFileName = options.DefaultFileName; this.CustomPlaces = new ObservableCollection <string>(); }