private void AddFileToDatabase(DatabaseReference database) { var dialog = new OpenFileDialog() { Filter = "All files|*.*", Multiselect = false }; if (dialog.ShowDialog() != true) { return; } try { if (InputBoxWindow.ShowDialog("New file id:", "Enter new file id", Path.GetFileName(dialog.FileName), out string id) == true) { var file = database.AddFile(id, dialog.FileName); SelectedCollection = database.Collections.First(a => a.Name == "_files"); ListCollectionData.SelectedItem = file; ListCollectionData.ScrollIntoView(ListCollectionData.SelectedItem); } } catch (Exception exc) { MessageBox.Show( "Failed to upload file:" + Environment.NewLine + exc.Message, "Database error", MessageBoxButton.OK, MessageBoxImage.Error ); } }