Original User: shirleyddThank you Jennifer! I did assign the Anchor property in the code-behind. The logic I used is to perform a identify task based on the mouseclick point. This identify task will work on three sublayers in one map services (19,20,21) and each of them needs different out fields. I give the mappoint to the anchor property(please see the red words). Did I miss something in my codes? Thank you!In mymap_mouseclick event:
ShowMapTip(sender as Map, e.MapPoint);
in ShowMapTip function:
private void ShowMapTip(Map map, MapPoint pnt)
{
if (ecocatParcelinfoWindow.IsOpen)
ecocatParcelinfoWindow.IsOpen = false;
if (!ecocatParcelinfoWindow.IsOpen)
{
ecocatParcelinfoWindow.Content = null;
IdentifyTask it = new IdentifyTask("http://rmms-dev.atlas.illinois.edu/ArcGIS/rest/services/wirt/MapServer");
var p = new IdentifyParameters()
{
MapExtent = MyMap.Extent,
Height = (int)MyMap.ActualHeight,
Width = (int)MyMap.ActualWidth,
SpatialReference = MyMap.SpatialReference,
Geometry = pnt
};
p.LayerOption = LayerOption.all;
p.LayerIds.AddRange(new int[] { 19,20,21 });
it.ExecuteCompleted +=new EventHandler<IdentifyEventArgs>(it_ExecuteCompleted);
it.Failed += IdentifyTask_Failed;
it.ExecuteAsync(p,pnt);
}
ecocatParcelinfoWindow.IsOpen = !ecocatParcelinfoWindow.IsOpen;
}
In identifytask_ExecuteCompleted event:
private void it_ExecuteCompleted(object sender, IdentifyEventArgs e)
{
if (e.IdentifyResults.Count == 0)
{
ecocatParcelinfoWindow.IsOpen = false;
return;
}
List<string> outfield = new List<string>();
if (e.IdentifyResults.ElementAt(0).LayerId == 19)
{
outfield.Add("COMMON_NAM");
outfield.Add("LAST_OBS_D");
outfield.Add("EO_NUM");
}
else if (e.IdentifyResults.ElementAt(0).LayerId == 20)
{
outfield.Add("MA_NAME");
outfield.Add("INPC_NUMBE");
}
else if (e.IdentifyResults.ElementAt(0).LayerId == 21)
{
outfield.Add("SITENAME");
outfield.Add("NAINUM");
}
IDictionary<string, object> attributes = new Dictionary<string, object>();
foreach (var item in e.IdentifyResults[0].Feature.Attributes)
if (outfield.Contains(item.Key))
attributes.Add(item.Key, item.Value);
MapPoint pnt = e.UserState as MapPoint;
ecocatParcelinfoWindow.Anchor = pnt;
ecocatParcelinfoWindow.IsOpen = true;
ecocatParcelinfoWindow.Content = attributes;
}