private void CreateNotebook(object arg) { MainWindowInstance.ShowInputAsync("Add notebook", "Name:").ContinueWith(delegate(Task <string> task) { string newName = task.Result; if (string.IsNullOrEmpty(newName)) { return; } Notebook nb = new Notebook { Name = newName, Created = DateTime.Now }; nb.Save(); var newNotebook = ViewModelLocator.Instance.GetNotebookViewModel(nb); List <NotebookViewModel> temp = new List <NotebookViewModel>(); temp.AddRange(Notebooks.ToArray()); temp.Add(newNotebook); temp.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); Notebooks.Clear(); temp.ForEach(Notebooks.Add); SelectedNotebook = newNotebook; SelectedNotebook.IsSelected = true; }); }