Esempio n. 1
0
        /// <summary>
        /// Instantiates the View and the ViewModel and sets the DataContext of the View to the ViewModel.
        /// </summary>
        public BookmarksTool()
        {
            // Create an instance of the BookmarksConfigurationView. This View provides the dialog for configuring the
            // bookmarks. Set the DataContext of the configView to a new instance of the BookmarkViewModel, and pass in
            // the Map and the collection of bookmarks.
            configView = new BookmarksConfigurationView()
            {
                Margin = new Thickness(0, 5, 0, 0)
            };

            // Get the collection of bookmarks that will be used throughout the add-in.  Note this has to come
            // from the View because the Bookmarks control's bookmarks collection is read-only.
            bookmarkCollection     = configView.BookmarksControl.Bookmarks;
            configView.DataContext = new BookmarksViewModel(MapApplication.Current.Map, bookmarkCollection);

            // Create an instance of the BookmarksNavigationView that is called when the icon on the toolbar is clicked. Set
            // the DataContext of the navView to the BookmarkViewModel, and pass in the Map and the collection of bookmarks.
            navView = new BookmarksNavigationView()
            {
                Margin = new Thickness(10)
            };
            navView.DataContext = new BookmarksViewModel(MapApplication.Current.Map, bookmarkCollection);

            // When the collection of bookmarks changes, notify the framework that the tool's execution state has changed
            bookmarkCollection.CollectionChanged += (o, e) => RaiseCanExecuteChanged();
        }
        /// <summary>
        /// Instantiates the View and the ViewModel and sets the DataContext of the View to the ViewModel. 
        /// </summary>
        public BookmarksTool()
        {
            // Create an instance of the BookmarksConfigurationView. This View provides the dialog for configuring the
            // bookmarks. Set the DataContext of the configView to a new instance of the BookmarkViewModel, and pass in
            // the Map and the collection of bookmarks. 
            configView = new BookmarksConfigurationView() { Margin = new Thickness(0, 5, 0, 0) };

            // Get the collection of bookmarks that will be used throughout the add-in.  Note this has to come
            // from the View because the Bookmarks control's bookmarks collection is read-only.
            bookmarkCollection = configView.BookmarksControl.Bookmarks;
            configView.DataContext = new BookmarksViewModel(MapApplication.Current.Map, bookmarkCollection);

            // Create an instance of the BookmarksNavigationView that is called when the icon on the toolbar is clicked. Set
            // the DataContext of the navView to the BookmarkViewModel, and pass in the Map and the collection of bookmarks.
            navView = new BookmarksNavigationView() { Margin = new Thickness(10) };
            navView.DataContext = new BookmarksViewModel(MapApplication.Current.Map, bookmarkCollection);

            // When the collection of bookmarks changes, notify the framework that the tool's execution state has changed
            bookmarkCollection.CollectionChanged += (o, e) => RaiseCanExecuteChanged();
        }