You can do this by listening to the FeatureLayer_MouseLeftButtonUp event handler. Use the following code snippet to get the attribute collection of the Graphic object that has been clicked by the user:IDictionary<string, object> attributes = e.Graphic.Attributes;
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args)
{
FeatureLayer featureLayer = sender as FeatureLayer;
for (int i = 0; i < featureLayer.SelectionCount; i++)
featureLayer.SelectedGraphics.ToList().UnSelect();
args.Graphic.Select();
IDictionary<string, object> attributes = args.Graphic.Attributes;
MessageBox.Show("This FID = " + attributes["FID"]) ;
}Please take a look a the following SDK sample to get the whole idea:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SelectGraphics
You would need to set the FeatureSymbol property of your FeatureLayer to your custom symbol.
<Grid.Resources>
<esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Red" Style="Diamond" Size="10" />
</Grid.Resources>
<esri:Map x:Name="MyMap" Grid.RowSpan="2" >
<esri:Map.Layers>
<esri:ArcGISDynamicMapServiceLayer ID="SchoolSearch3"
Url="http://198.182.104.173/ArcGIS/rest/services/SchoolSearch3/MapServer" VisibleLayers="0,1"/>
<esri:FeatureLayer ID="MyFeatureLayer"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0"
MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"
DisableClientCaching="True"
Mode="OnDemand"
OutFields="*"
SelectionColor="Yellow"
FeatureSymbol="{StaticResource MyMarkerSymbol}" >
</esri:FeatureLayer>
</esri:Map.Layers>
</esri:Map> which seems to work as expected except that I don't get the yellow selected color. However, when I substitute MY url in place of the sample, (Url="http://198.182.104.173/ArcGIS/rest/services/Intersection_Test/MapServer/0") it does not work. So the conclusion is that I must need to do something to the service to make this work? Correct? and if so what?
<esri:FeatureLayer ID="MyFeatureLayer" Renderer="{StaticResource PointSymbol}" ... />
<Grid.Resources>
<esri:MarkerSymbol x:Key="SelectMarkerSymbol" >
<esri:MarkerSymbol.ControlTemplate>
<ControlTemplate>
<Ellipse x:Name="Element" Width="15" Height="15" StrokeThickness="10"
Stroke="Green" >
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimation Storyboard.TargetName="Element"
Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)"
To="Cyan" Duration="00:00:0.25"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Ellipse>
</ControlTemplate>
</esri:MarkerSymbol.ControlTemplate>
</esri:MarkerSymbol>
<esri:SimpleRenderer x:Key="PointSymbol" Symbol="{StaticResource SelectMarkerSymbol}" />
</Grid.Resources>
You can look at this help doc http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#/Authoring_fea...
There is a section on defining symbology.