Select to view content in your preferred language

GraphicsLayer for selected Feature

798
4
08-11-2010 05:11 AM
UlfGrimhardt
Deactivated User
Hi,

I have a ComboBox which shows the Names of some Features in my Layer.
Now i would like to higlight the selected Feature with a red dot, so i need to add a graphics layer to it right?

My Question is, how can i get the Feature to add it to the GraphicsLayer?
Is the FindTask or QueryTask the only way? Can't i just say something like GraphicsLayer.Graphics.add(FeatureID)?
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
I think it would be easiest if your ComboBox ItemSource is bound to the FeatureLayer's graphics, that way when a feature name is selected, you can get the graphic from ComboBox selection and add it to a GraphicsLayer.

Something like:
<ComboBox ItemSource={Binding ElementName=MyMap, Path=Layers[FeatureLayerID].Graphics >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBox Text={Binding Attributes[Name]>...

Subscribe to the ComboBox SelectionChanged event and add this graphic to your GraphicsLayer. Your GraphicsLayer can be defined with a SimpleRenderer that has SimpleMarkerSymbol (Circle, Red) so you would only need to add graphic in code without worrying about its symbol.

Jennifer
0 Kudos
TonyBacon
Deactivated User
Check this sample out, it uses a mouse over events for the data rows in a grid and also the graphics in a feature layer to highlight a feature and its data row. http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#SpatialQuery
0 Kudos
UlfGrimhardt
Deactivated User
Thanks for your replies!

I tried this:

<ComboBox Grid.ColumnSpan="2" Margin="4,6" Name="ms_detail_combo" Grid.Column="2" Grid.Row="1" ItemsSource="{Binding ElementName=map, Path=Layers.[0].Graphics}" IsEnabled="False">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding [Messstelle]}"></TextBox>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

But my ComboBox doesnt show any Items. I think the Path of my ItemSource is wrong, but iam not quiet sure.
I have a MXD with two Features, and i want to show the Attributes of the first Feature. So my ArcGISDynamicMapServiceLayer is the only Layer i got, but dont i have to set the Sublayer (My first Feature that has Attriubute Messsstelle) as ItemSource? How can i do that in XAML?
0 Kudos
JenniferNery
Esri Regular Contributor
Since you are using ArcGISDynamicMapServiceLayer, it's Layers will be loaded after it has been initialized. So you need to set your ComboBox ItemSource property in code-behind inside your Intialized eventhandler.
0 Kudos