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"
                             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:

                        <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" >


1 Answer 1


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


<esri:InfoWindow x:Name="MyInfoWindow"
                             Background="{StaticResource PanelGradient}"
                             Map="{Binding ElementName=MyMap}"
                             ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}">                


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.