Select to view content in your preferred language

When is map Loaded called

1026
2
07-26-2010 09:57 PM
xariaD
by
Occasional Contributor
I need to do some processing on the feature layer after the map is loaded.
How can I capture Map Loaded event complete?

After the map is loaded I need to do the following
private void ProjectFeatures()
{
FeatureLayer newFeaturelayer;
            
            newFeaturelayer = MyMap.Layers["myFeaturelayer"] as FeatureLayer;
            
            
            Graphic feature = new ESRI.ArcGIS.Client.Graphic();
            int[] statuses = MyWebServiceProxy.GetAllStatus(UserInfo.username,1);   
            for (int i = 0; i < 12; i++)
               {
                   feature = newFeaturelayer.Graphics;
                   if (statuses == 0)
                   {
                       feature.Attributes["Status"] = "Off";
                       feature.Symbol = this.MainGrid.Resources["MyRedFillSymbol"] as SimpleFillSymbol;
                   }
                   else
                   {
                       feature.Attributes["Status"] = "On";
                       feature.Symbol = this.MainGrid.Resources["MyGreenFillSymbol"] as SimpleFillSymbol;
                   }
               }     
}     


If I call this in  private void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            MyMap.Rotation = 90;
            ProjectFeatures();
        }
I get System.ArgumentOutofRange exception at   feature = newFeaturelayer.Graphics;

Where will be the appropriate place to invoke this function.
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor

I get System.ArgumentOutofRange exception at feature = newFeaturelayer.Graphics;

Where will be the appropriate place to invoke this function.


It means that at this stage the graphics are not existing yet --> call this function after the graphics of your feature layer are loaded.
So it's depending on where your graphics are coming from:
    - if defined in xaml --> call your function in the Initialized event of the feature layer
    - if defined by code --> call it after this code
    - if coming from a feature layer --> call it in the UpdateCompleted event
   ......
0 Kudos
xariaD
by
Occasional Contributor
Thanks Dominique

I'll try calling the code in UpdateCompleted
0 Kudos