Dominique,I placed you code in application and initially it didn't work but then I created a new selection button using the example from http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelectionand it works. Next I modify the code I was originally trying to use and got it to work also (see below). I guess my problem is, I am want to use the spatial selection (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SpatialQuery) tools and not this tool that I just created that only works on one specific feature layer. I tried to fuse the two and did some searching and couldn't find a solution. It seems like my problem with the spatial selection tools is I am setting the featuredatagrid.Graphicslayer to a graphics layer and not feature layer because of how the spatial selection tool works. I keep coming back to writing a simple if that will check if MyActiveLayer is a featurelayer and if so (per you suggestion) on this post http://forums.arcgis.com/threads/47996-Feature-Data-Grid-Editing set MyFeatureDataGrid.GraphicsLayer = MyActiveLayer; but my MyActiveLayer is a graphic layer even if it is based off a Editable FeatureLayer it doesn't work...hope you can follow this.I keep trying this but this doesn't work either.
{
if (MyActiveLayer.SelectedIndex == 2 || (MyActiveLayers.SelectedIndex == 3) // Layer is none Editable Feature Layer, without attachments
{
foreach (Graphic feature in featureSet.Features)
{
switch (featureSet.GeometryType.ToString())
{
case "Polygon":
feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;
break;
case "Polyline":
feature.Symbol = LayoutRoot.Resources["CustomGrowLineSymbol"] as LineSymbol;
break;
case "Point":
feature.Symbol = LayoutRoot.Resources["ResultsMarkerSymbol"] as SimpleMarkerSymbol;
break;
}
MyFeatureDataGrid.GraphicsLayer = graphicsLayer;
graphicsLayer.Graphics.Insert(0, feature);
}
}
if ((MyActiveLayers.SelectedIndex == 0 || (MyActiveLayers.SelectedIndex == 1) // Layer is a Editable Feature Layer, has attachments
{
foreach (Graphic feature in featureSet.Features)
{
switch (featureSet.GeometryType.ToString())
{
case "Polygon":
feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;
break;
case "Polyline":
feature.Symbol = LayoutRoot.Resources["CustomGrowLineSymbol"] as LineSymbol;
break;
case "Point":
feature.Symbol = LayoutRoot.Resources["ResultsMarkerSymbol"] as SimpleMarkerSymbol;
break;
}
graphicsLayer.Graphics.Insert(0, feature);
FeatureLayer featurelayer = graphicsLayer as FeatureLayer;
MyFeatureDataGrid.GraphicsLayer = featurelayer;
}
}
My modified FeatureDataGrid_Selection Change that works with the feature layer selection button from SDK (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelection) private void FeatureDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var fdg = sender as ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid;
foreach (var item in e.AddedItems)
{
var g = GetGraphicSibling(item);
if (g.Layer is FeatureLayer)
{
MyAttachmentEditor.FeatureLayer = fdg.GraphicsLayer as FeatureLayer;
MyAttachmentEditor.GraphicSource = g;
}
}
}
private static Graphic GetGraphicSibling(object item)
{
if (item != null)
{
MethodInfo mi = item.GetType().GetMethod("GetGraphicSibling");
if (mi != null)
{
return mi.Invoke(item, null) as Graphic;
}
}
return null;
}