private void OnNewDatabaseRequested(ObservableTreeItem item) { try { if (item != null && SelectedItem.Type == ItemTypeModel.Folder) { AddDatabaseDialog dialog = new AddDatabaseDialog(); if (dialog.ShowDialog() ?? false) { string databasePath = dialog.DatabaseName.EndsWith(".db") ? Path.Combine(SelectedItem.Path, dialog.DatabaseName) : Path.Combine(SelectedItem.Path, String.Concat(dialog.DatabaseName, ".db")); _sqliteService.BuildDatabase(databasePath); item.Items.Add(new ObservableTreeItem { Name = dialog.DatabaseName, Path = databasePath, Type = ItemTypeModel.Database }); ItemsCollectionChanged(this, new ItemsCollectionChangedEventArgs(Items.SelectMany(i => i.Items))); } } else { WpfMessageBox.ShowDialog("Invalid Item Selected", "Please select a folder to add a database to.", MessageBoxButton.OK, MessageIcon.Error); } } catch (Exception ex) { WpfMessageBox.ShowDialog("Error Building Database", ex.Message, MessageBoxButton.OK, MessageIcon.Error); } }