The ESRI sample (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid) shows a way to create an interactive data table for GraphicLayer (click the map, associated feature will highlight in the FeatureDataGrid, Vice versa). The core part is the FeatureLayer_MouseLeftDown function as below:private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs args) { args.Graphic.Selected = !args.Graphic.Selected; if (args.Graphic.Selected) MyDataGrid.ScrollIntoView(args.Graphic, null); }
XAML code from Sample:<esri:FeatureLayer ID="California" Renderer="{StaticResource SelectRenderer}" Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/8" OutFields="*" MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown" /> ... <esri:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid" Map="{Binding ElementName=MyMap}" GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[California]}" /> The map user click actually is a feature layer and the featureDataGrid is binding to a GraphicsLayer (the same feature layer anyway). I make some changes from the sample for my application. If I get rid of the feature layer and the GraphicsLayer is returned from a query and I worte a similar GraphicsLayer_MouseLeftButton Down function, if you click the map, the entry in the FeatureDataGrid can be highlighted, but when I click a row in the FeatureDataGrid, the feature on the map doesn't highlight. What do I miss here? private void GraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) { e.Graphic.Selected = !e.Graphic.Selected; if (e.Graphic.Selected) MyDataGrid.ScrollIntoView(e.Graphic, null); }
The XAML from my code:<esri:GraphicsLayer ID="MyGraphicsLayer" MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown" /> .... <esri:FeatureDataGrid x:Name="MyDataGrid" Background="White" Map="{Binding ElementName=MyMap}" GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[MyGraphicsLayer]}" > </esri:FeatureDataGrid>