Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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;
            }
        }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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