ThinkGeo.com    |     Documentation    |     Premium Support

EventArgs for WPF?

Im using WPF to display map and for user interface. Is there any event handler args  for WPF maps like in winforms:


winformsMap1_MapClick(object sender, WinformsMapClickEventArgs e)


so that i can get some map-specific args like e.WorldX and e.WorldY?


 



Here is a WPF demo for you, Ric. Click on the US and the corresponding state will be highlighted. 



Thanks,


Ben



506-WpfDemoWithMapClick.zip (102 KB)

Yes Ben, but how can we know what types of event data generated byt the event are available for WPF? is there any list, or we just look at Intellisense like when we type "wpfMap1.MapClick+=" then press TAB key, to see the "WpfMapClickEventArgs<wpfmapclickeventargs></wpfmapclickeventargs>"? 

 






 


Ric,


Open the API Documentation and search “eventargs”, you will see all the event args within our system.  The one starts with “Wpf” is available specific for wpf component. For now, you can see there is only one “WpfMapClickEventArgs”. For its own events of a wpf component, we need to check msdn to find what's their event args. For example, wpfMap1.MouseDown event uses the “MouseButtonEventArgs”, we need to check it ourselves how to use it.



Thanks,


Ben




i see Ben, so there is only 1  “WpfMapClickEventArgs” for wpf for now. Im trying to display world coordinates on the screen whenever the mouse moves. For mouse clicks, i know we can implement in this way:




private void wpfMap1_MapClick(object sender, WpfMapClickEventArgs e)
{
    tbWorldX.Text = e.WorldX.ToString();
    tbWorldY.Text = e.WorldY.ToString();
}



So my problem is, without the "WpfMapClickEventArgs";, i can't access world coordinates using "e.WorldX" or "e.WorldY". This is what i did:





void wpfMap1_MouseMove(object sender, MouseEventArgs e)
{
    screenX.Text = e.GetPosition(wpfMap1).X.ToString();
    screenY.Text = e.GetPosition(wpfMap1).Y.ToString();
}



i dont have idea how to convert x and y (which is screen coordinates) to world coordinates...



Ric, 
  
 There is an API to convert screen coordinates to world coordinates, here is the codes. 
  
 
 Point currentPoint = e.GetPosition(wpfMap1);
            ScreenPointF screenPointF = new ScreenPointF((float)currentPoint.X, (float)currentPoint.Y);
            PointShape pointInWorldCoordinate =  ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.Width, (float)wpfMap1.Height);
             
 Thanks, 
  
 Ben 


Ben, 
  
 It worked. You must have a very deep understanding of all the aspects of Thinkgeo platforms! 
  
 Ric

That’s because I have a great team behind me. :-)