ArcGIS Silverlight API – Displaying Information on a Map Using an InfoWindow

arcgis-10.0arcgis-silverlight-apicinfowindowwpf

I am wanting to display information in an InfoWindow when the user clicks on a point on the map. I have implemented the InfoWindow in XAML, but I do not understand the code behind it. Any information will be appreciated. Here is my (what I feel is relevant) XAML:

 <esri:InfoWindow x:Name="MyInfoWindow"
                             Padding="2"
                             CornerRadius="20"
                             Background="{StaticResource PanelGradient}"
                             Map="{Binding MyMap}"
                             ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}"
                         MouseLeftButtonUp="MyInfoWindow_MouseLeftButtonUp" />

If you need anymore information, let me know. I have the information being displayed correctly at the moment in a MapTip. Here is the XAML for that:

<esri:FeatureLayer.MapTip>
                        <Border CornerRadius="10" BorderBrush="Black" BorderThickness="2" Margin="0,0,15,15" Background="{StaticResource PanelGradient}">
                            <StackPanel Margin="7">
                                <TextBlock Text="{Binding [WVAL_ID], StringFormat='ID: \{0\}'}" FontWeight="Bold" Foreground="White"  />
                                <TextBlock Text="{Binding [SIZE], StringFormat='Size: \{0\}'}" FontWeight="Bold" Foreground="White" />
                                <TextBlock Text="{Binding [WVAL_USE], StringFormat='Use: \{0\}'}" FontWeight="Bold" Foreground="White" />
                                <TextBlock Text="{Binding [WVAL_TYPE], StringFormat='Type: \{0\}'}" FontWeight="Bold" Foreground="White"  />
                                <TextBlock Text="{Binding [OPENS], StringFormat='Opens: \{0\}'}" FontWeight="Bold" Foreground="White"  />
                                <TextBlock Text="{Binding [TURNS], StringFormat='Turns: \{0\}'}" FontWeight="Bold" Foreground="White"  />
                                <StackPanel Orientation="Horizontal" >

                                </StackPanel>
                            </StackPanel>
                        </Border>
                    </esri:FeatureLayer.MapTip>

Best Answer

I finally figured it out for the most part...

XAML:

<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;
            }
        }
Related Question