private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(Catalog) || string.IsNullOrWhiteSpace(Description) || string.IsNullOrWhiteSpace(Path) || string.IsNullOrWhiteSpace(LineText)) { MessageBox.Show("data cannot be empty."); return; } if (Id == 0) { // add new bookmark var bookmarkItem = new Bookmarks.BookmarkItem(); bookmarkItem.ParentItem = ParentBookmarkItem == null ? null : ParentBookmarkItem.Core; bookmarkItem.Catalog = Catalog; bookmarkItem.Index = Index; bookmarkItem.Description = Description; bookmarkItem.Locations = new List <BookmarkLocation>(); bookmarkItem.Locations.Add(new BookmarkLocation() { FileLocation = Path, LocateLineNumber = LineNumber, LocateLineText = LineText, }); ViewContainer.Controller.CreateBookmark(bookmarkItem); } else { var bookmarkItem = new Bookmarks.BookmarkItem(); bookmarkItem.Id = Id; bookmarkItem.Catalog = Catalog; bookmarkItem.Index = Index; bookmarkItem.Description = Description; bookmarkItem.Locations = new List <BookmarkLocation>(); bookmarkItem.Locations.Add(new BookmarkLocation() { FileLocation = Path, LocateLineNumber = LineNumber, LocateLineText = LineText, }); ViewContainer.Controller.UpdateBookmark(bookmarkItem); } ViewContainer.LeaveWriterView(); }