Yes. I didn't read the example carefully enough. I made that changed and used the ID from xaml, but now I'm getting a NullReferenceException on this part.
foreach (int x in EMDataLayer.VisibleLayers)
identifyParams.LayerIds.Add(x);
Here's the full code.
private void QueryPoint_Click(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
if (IdentifyBtn.IsChecked.Value)
{
ArcGISDynamicMapServiceLayer EMDataLayer = (ArcGISDynamicMapServiceLayer)Map.Layers["Data"];
IdentifyBorder.Visibility = System.Windows.Visibility.Visible;
ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;
ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
{
Geometry = clickPoint,
MapExtent = Map.Extent,
Width = (int)Map.ActualWidth,
Height = (int)Map.ActualHeight,
LayerOption = LayerOption.all,
SpatialReference = Map.SpatialReference
};
foreach (int x in EMDataLayer.VisibleLayers)
identifyParams.LayerIds.Add(x);
IdentifyTask identifyTask = new IdentifyTask(EMDataLayer.Url);
identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
identifyTask.Failed += IdentifyTask_Failed;
identifyTask.ExecuteAsync(identifyParams);
GraphicsLayer graphicsLayer = Map.Layers["IDGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = clickPoint,
Symbol = LayoutRoot.Resources["IDPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
};
graphicsLayer.Graphics.Add(graphic);
}