views:

12

answers:

0

Hello-

I'm using Silverlight 3.0 with ArcGIS Server and when my application is loading if I hover my mouse over the map control I get an "Object not set to an instance of an object" on the MyMap_MouseMove function which is supposed to return X,Y coordinates to a label. That makes sense because my map hasn't fully loaded and I'm asking it for data it doesn't have yet. So how can I wait until the map is ready before getting the XY data in MyMap_MouseMove?? Below is my MouseMove function

 private void MyMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs args)
        {

            System.Windows.Point screenPoint = args.GetPosition(map1);

            ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = map1.ScreenToMap(screenPoint);
            MapCoordsTextBlock.Text = string.Format("Map Coords: X = {0}, Y = {1}",
            Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4));

        }