Select to view content in your preferred language

What event to handle when Selected Features are returned

936
6
05-18-2010 08:39 AM
MikeKaufman
Emerging Contributor
I am using the Editor to do selections on a feature layer in ???MyMap??? control.   There are a few other things that I want to do after the selected graphics have returned from the service.   What is the best event/binding to handle when using the editor to notify me when the selected graphics have returned?  I have tried to use the Update Complete on the Feature Layer but that does not fire when mode is set to SelectionOnly.  I want to iterate through the graphics to generate a list of attributes.  I will be sending this list to query additional information for a database.
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
You can use the Editor's EditCompleted event.

        private void MyEditor_EditCompleted(object sender, Editor.EditEventArgs e)
        {
            if (e.Action == Editor.EditAction.Select)
            {
                foreach (Editor.Change item in e.Edits)
                {
                    Graphic graphic = item.Graphic; //selected graphic
                    Layer layer = item.Layer;
                }
            }
        }
0 Kudos
MikeKaufman
Emerging Contributor
Thanks for the reply...that event works perfect.  I didn't try EditComplated because I thought it would fire to soon.
0 Kudos
MikeKaufman
Emerging Contributor
You can use the Editor's EditCompleted event.

        private void MyEditor_EditCompleted(object sender, Editor.EditEventArgs e)
        {
            if (e.Action == Editor.EditAction.Select)
            {
                foreach (Editor.Change item in e.Edits)
                {
                    Graphic graphic = item.Graphic; //selected graphic
                    Layer layer = item.Layer;
                }
            }
        }


So now I am expecting this event to fire when I hit Clear (when the ClearSelection Comand is called) but it seems that the event is not firing.  Has anyone ran into this issue?
0 Kudos
JenniferNery
Esri Regular Contributor
EditCompleted event should be fired, the action you should be checking for is Editor.EditAction.ClearSelection.

You may also use the layer's PropertyChanged event, when e.PropertyName is "SelectedGraphics" or "SelectionCount".

I hope that helps.
0 Kudos
MikeKaufman
Emerging Contributor
The editCompleted does not fire for me on the clear command.  I have not tried the 2.0 RC api version yet.  But I think there might be a bug with that event not getting raised.


EditCompleted event should be fired, the action you should be checking for is Editor.EditAction.ClearSelection.

You may also use the layer's PropertyChanged event, when e.PropertyName is "SelectedGraphics" or "SelectionCount".

I hope that helps.
0 Kudos
JenniferNery
Esri Regular Contributor
If you are using the EditorWidget or made a button with Command bound to the Editor's ClearSelection, the Editor's EditCompleted will fire when this command has successfully cleared selection. The Action you are looking for is ClearSelection. ArcGIS API for SL/WPF v2.0.

If you are not using this version, your best bet will be to listen to PropertyChanged event on the layer. The Property you are looking for is SelectionCount or SelectedGraphics.
0 Kudos