/// <summary> /// Gets whether the command can be executed. Ensures that there is a bookmark to delete. /// </summary> /// <param name="parameter">The bookmark to delete</param> /// <returns>Returns true if there is a bookmark to delete and it belongs to the <see cref="Bookmarks"/> collection</returns> public bool CanExecute(object parameter) { // Make sure the bookmarks collection is initialized and that the // passed-in bookmark is in the collection Bookmark.MapBookmark bookmark = parameter as Bookmark.MapBookmark; return(Bookmarks != null && bookmark != null && Bookmarks.Contains(bookmark)); }
#pragma warning restore 67 /// <summary> /// Deletes the bookmark passed as the parameter. /// </summary> /// <param name="parameter">Utilizes the DataContextProxy via Binding on the DeleteBookmark button /// to specify the bookmark to delete.</param> public void Execute(object parameter) { if (!CanExecute(parameter)) { throw new ArgumentException(Strings.CannotDeleteBookmarkError); } Bookmark.MapBookmark bookmark = parameter as Bookmark.MapBookmark; Bookmarks.Remove(bookmark); }