private void ButtonAddDone_Click(object sender, RoutedEventArgs e)
{
// Get the name from the text field
var name = TextBoxBookmarkName.Text;
// Exit if the name is empty
if (string.IsNullOrEmpty(name))
return;
// Check to see if there is a bookmark with same name
bool doesNameExist = MyMapView.Map.Bookmarks.Any(b => b.Name == name);
if (doesNameExist)
return;
// Create a new bookmark
Bookmark myBookmark = new Bookmark();
myBookmark.Name = name;
// Get the current viewpoint from map and assign it to bookmark
myBookmark.Viewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
// Add the bookmark to bookmark collection of the map
MyMapView.Map.Bookmarks.Add(myBookmark);
// Add the bookmark to the list of choices in the combo box
bookmarkChooser.Items.Insert(bookmarkChooser.Items.Count, myBookmark);
// Set the newly added bookmark to be the one selected in the combo box
bookmarkChooser.SelectedItem = myBookmark;
// Hide the controls to add a bookmark
BorderAddBookmark.Visibility = Visibility.Collapsed;
ButtonAddBookmark.Visibility = Visibility.Visible;
}
}