I have some a control that allows a user to add a shapefile to the map as a graphics layer. I added a MouseLeftButtonDown event that opens an InfoWindow. I would like InfoWindow to have all of the attributes from the graphicLayer, but I don???t how to bind the attributes to InfoWindow text without knowing their names first.I guess what I would like to have happen is for a textblock to be added to my InfoWindow template for each attribute field in my graphic, and for the text of the textblock to be the attribute value. Anyone have an idea how to get this to work? Here are the pertinent portions of my code:void GraphicClick(object sender, GraphicMouseButtonEventArgs e)
{
Graphic gra = e.Graphic;
MapPoint myMapPoint = new MapPoint();
myMapPoint = gra.Geometry as MapPoint;
InfoWindow myInfoWindow = new InfoWindow();
myInfoWindow.Content = e.Graphic.Attributes;
myInfoWindow.Anchor = myMapPoint;
myInfoWindow.IsOpen = true;
myInfoWindow.Map = MapApplication.Current.Map;
myInfoWindow.ContentTemplate = LayoutRoot.Resources["InfoWindowTemplate"] as System.Windows.DataTemplate;
LayoutRoot.Children.Add(myInfoWindow);
myInfoWindow.MouseLeftButtonDown += new MouseButtonEventHandler(MyInfoWindow_MouseLeftButtonDown);
}
<Grid.Resources>
<DataTemplate x:Key="InfoWindowTemplate" x:Name="InfoWindowTemplate">
<StackPanel x:Name="InfoStack" Orientation="Vertical" Margin="10,10,10,10" Background="Transparent">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Background="Transparent">
<TextBlock Text="Field Name: " FontWeight="Bold"/>
<TextBlock x:Name="textValue" >
</StackPanel>
</StackPanel>
</DataTemplate>
</Grid.Resources>