private void RefreshNotebooksAndNotes()
        {
            this.Notebooks = null;
            var localNotebooks = new ObservableCollection <NotebookViewModel>();

            // Add the default notebooks
            localNotebooks.Add(NotebookViewModel.CreateAllNotesNotebook());
            localNotebooks.Add(NotebookViewModel.CreateUnfiledNotesNotebook());

            foreach (Notebook nb in this.noteService.GetNotebooks(ref this.totalNotebooks))
            {
                localNotebooks.Add(new NotebookViewModel()
                {
                    Notebook   = nb,
                    FontWeight = "Normal",
                    IsDragOver = false
                });
            }

            this.Notebooks = localNotebooks;

            // Because we cannot pass a Property by reference aboves
            OnPropertyChanged(() => this.TotalNotebooks);

            // Set the default selected notebook (Setting the selected notebook, triggers a refresh of the notes.)
            this.SetDefaultSelectedNotebook();

            // This makes sure the View is notified that the Notebooks collection has changed.
            // If this call is missing, the list of Notebooks is not updated in the View after
            // we changed its elements here. OnPropertyChanged("Notebooks")
            this.eventAggregator.GetEvent <NotebooksChangedEvent>().Publish("");
        }
        private void NewNote(object param)
        {
            bool createUnfiled = Convert.ToBoolean(param);

            try
            {
                string initialTitle = this.noteService.GetUniqueNoteTitle(ResourceUtils.GetString("Language_New_Note"));

                FlowDocument flowDoc = new FlowDocument();

                Notebook theNotebook = default(Notebook);

                if (!createUnfiled & (this.SelectedNotebook != null && !this.SelectedNotebook.IsDefaultNotebook))
                {
                    theNotebook = this.SelectedNotebook.Notebook;
                }
                else
                {
                    theNotebook = NotebookViewModel.CreateUnfiledNotesNotebook().Notebook;
                }

                NoteWindow notewin = new NoteWindow(initialTitle, "", theNotebook, this.searchService.SearchText, true, this.appearanceService, this.jumpListService, this.eventAggregator, this.noteService,
                                                    this.dialogService);

                notewin.ActivateNow();

                RefreshNotes();
            }
            catch (Exception)
            {
                this.dialogService.ShowNotificationDialog(null, title: ResourceUtils.GetString("Language_Error"), content: ResourceUtils.GetString("Language_Problem_Creating_Note"), okText: ResourceUtils.GetString("Language_Ok"), showViewLogs: false);
            }
        }