I am trying to display information in an InfoWindow when the user clicks on a point on a map. I have the content in the InfoWindow and it is popping up. The only problem is the InfoWindow pops up no matter where you click on the map and it just displays the information from the previous Grapic point clicked. Any help would be appreciated. Here is my code:
XAML:
<esri:Map x:Name="MyMap" Background="#FFE3E3E3" WrapAround="True" MouseClick="MyMap_MouseClick" MouseRightButtonDown="MyMap_MouseRightButtonDown" Extent="-9834972.92753924,4441899.425293319,-9833977.88119163, 4442762.485358352">
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer ID="MyLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
<esri:ArcGISDynamicMapServiceLayer ID="Calvert_City" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer"/>
<esri:FeatureLayer ID="Water_Valves" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer/0" Renderer="{StaticResource MySimpleRenderer}"
OutFields="WVAL_ID,SIZE,WVAL_USE,WVAL_TYPE,OPENS,TURNS" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"/>
</esri:Map.Layers>
</esri:Map>
<esri:InfoWindow x:Name="MyInfoWindow"
Padding="2"
CornerRadius="20"
Background="{StaticResource PanelGradient}"
Map="{Binding ElementName=MyMap}"
ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}">
</esri:InfoWindow>
C#:
MapPoint lastPoint = null;
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
{
FeatureLayer flayer = sender as FeatureLayer;
MapPoint clickpoint = MyMap.ScreenToMap(e.GetPosition(MyMap));
if (clickpoint != lastPoint)
{
MyInfoWindow.Anchor = clickpoint;
MyInfoWindow.Content = e.Graphic.Attributes;
MyInfoWindow.IsOpen = true;
lastPoint = clickpoint;
}
}
If you need any more information, just let me know. Thanks.