The 'esri_mapping_popupToolContextMenu' has a couple of items in it that access the map coordinates from the click event calling the context menu. Since I have my own button/item in the 'esri_mapping_popupToolContextMenu' I would like to access these coordinates to use them in the OnClick method of my button.
How can I get these coordinates?
Solved! Go to Solution.
Thomas,
You can use FrameworkApplication.ContextMenuDataContext to cast to a windows point then make a mappoint out of it in your buttons click method.
    protected override void OnClick()
    {
      //get the screen location of the right click
      var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;
      QueuedTask.Run(async() =>
        {
          var mapPoint = MapView.Active.ScreenToMap(cmdc);
          
          //create search polygon at 5 pixels
          var searchPoly = CreateSearchPolygon(mapPoint, 5);
          //find features under the search geometry
          var searchFeatures = MapView.Active.GetFeatures(searchPoly);The full sample can be found here: Replace Sketch
Thomas,
You can use FrameworkApplication.ContextMenuDataContext to cast to a windows point then make a mappoint out of it in your buttons click method.
    protected override void OnClick()
    {
      //get the screen location of the right click
      var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;
      QueuedTask.Run(async() =>
        {
          var mapPoint = MapView.Active.ScreenToMap(cmdc);
          
          //create search polygon at 5 pixels
          var searchPoly = CreateSearchPolygon(mapPoint, 5);
          //find features under the search geometry
          var searchFeatures = MapView.Active.GetFeatures(searchPoly);The full sample can be found here: Replace Sketch