private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs args) { args.Graphic.Selected = !args.Graphic.Selected; if (args.Graphic.Selected) MyDataGrid.ScrollIntoView(args.Graphic, null); }
<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>
Solved! Go to Solution.
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?
Map="{Binding ElementName=MyMap}"
Most generally this means that the Map of the FeatureDataGrid is not or badly initialized.
If this is the only location you initialize the MapMap="{Binding ElementName=MyMap}"
my best bet would be that the Map is not called 'MyMap'.
Check that point. I have no others ideas anyway.
Did you check taht your map is called 'MyMap' ?
Did you check taht your map is called 'MyMap' ?Positive! My map is called "MyMap" and I only initialize the FeatureDataGrid once in the XAML. I don't have any clue about what's wrong.
private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs args) { args.Graphic.Selected = !args.Graphic.Selected; if (args.Graphic.Selected) MyDataGrid.ScrollIntoView(args.Graphic, null); }
You can look at this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid
Code-behind (this can also be on GraphicsLayer_MouseLeftButtonDown):private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs args) { args.Graphic.Selected = !args.Graphic.Selected; if (args.Graphic.Selected) MyDataGrid.ScrollIntoView(args.Graphic, null); }
FeatureDataGrid.GraphicsLayer can be bound to a GraphicsLayer. It's fields will come from GraphicsLayer.Graphics.Attributes.