Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
Dim SelectionLayer As FeatureLayer = CType(Me.MyMap.Layers("CensusDemographics"),FeatureLayer)
SelectionLayer.Mode = ESRI.ArcGIS.Client.FeatureLayer.QueryMode.Snapshot
SelectionLayer.Where = "POP2000 < 100"
SelectionLayer.UpdateCompleted = (SelectionLayer.UpdateCompleted + SelectionLayer_UpdateCompleted)
SelectionLayer.Update
End Sub
Private Sub SelectionLayer_UpdateCompleted(ByVal sender As Object, ByVal e As System.EventArgs)
SelectionLayer = CType(sender,ESRI.ArcGIS.Client.FeatureLayer)
SelectionLayer.UpdateCompleted = (SelectionLayer.UpdateCompleted - SelectionLayer_UpdateCompleted)
SelectionLayer.Mode = ESRI.ArcGIS.Client.FeatureLayer.QueryMode.SelectionOnly
SelectionLayer.Where = "1=1"
SelectionLayer.Update
End Sub
Also, I'm not sure why you would want to switch the mode of FeatureLayer at run-time. Using the layer for dual purpose does not sound like a good approach(just my opinion).
I am using the editor to make spatial selections but also need the capability to make a selection by querying the attributes.
SelectionLayer.Where = "1=1" SelectionLayer.Update()
Ah okay. I was not able to run the project directly. I had to copy VB code and translate to C#.
At any case, Update() is essential when the parameters of the Query changes. Since Where part changed, you need to run the Query again.
http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay...
I'm sorry that I am also confused with what you are trying to achieve with your code. It seems that the only time the layer is in Snapshot mode is when you click the button, right? At which time, you call update(), once update is complete, you change the layer back to SelectionOnly mode. While switching modes, you also update Where clause. If you do not need to update Where clause then Update() does not need to be called.
I think that it's better to have two FeatureLayers one for each mode to avoid confusion. The use case you described here is not supported and I am not sure what other issues you may encounter when toggling modes without calling Update().
If you wish to continue with your current code. A workaround is to also include ObjectID in your OutFields.