1

For feature Layer in want to show user an info window for information. I m able show the infowindow but It is not loading with data. i can see the Attributes in Graphic which is setting in Content but still Nothing in visible in Info window.

I followed Using InfoWindow with Feature Layer and DialogWindowBase?

http://silverlightchina.net/html/tips/2011/0524/7863.html

Displaying information on a map using an InfoWindow

useful code in my ViewModel when FeatureLayer get generated

 private void mapLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
    {
        FeatureLayer amLyr = sender as FeatureLayer;
        Graphic selectedGraphic = e.Graphic;
        //HpmInfoWindow.DataContext = selectedGraphic.Attributes;            
        MapPoint clickpoint = HpmMap.ScreenToMap(e.GetPosition(HpmMap));
        if (RouteLayerInforWindowAnchor != clickpoint)
        {
            HpmInfoWindow.Content = selectedGraphic.Attributes;
            HpmInfoWindow.Anchor = clickpoint;
            HpmInfoWindow.IsOpen = true;
            RouteLayerInforWindowAnchor = clickpoint;
        }

    }
    private InfoWindow _HpmInfoWindow;
    public InfoWindow HpmInfoWindow
    {
        get
        {
            return _HpmInfoWindow;
        }
        set
        {
            _HpmInfoWindow = value;
            RaisePropertyChanged(() => HpmInfoWindow);
        }
    }

in XAML

 <esri:InfoWindow x:Name="HpmInfoWindow"
                     Padding="5"
                     CornerRadius="20"
                     Background="BlueViolet"
                     Map="{Binding ElementName=HpmEsriBaseMap}"
                     ContentTemplate="{StaticResource InfoWindotemplateRoutes}">
        </esri:InfoWindow>

  <Grid.Resources>
            <DataTemplate x:Key="InfoWindotemplateRoutes">
                <Grid x:Name="incoLayoutRoot" Background="White" Width="200" Height="200">
                    <StackPanel Margin="7">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Route Info :  " FontWeight="Bold" Foreground="Black" />
                            <TextBlock Text="{Binding [ROUTE_ID]}" FontWeight="Bold" Foreground="Black"  />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Year: " Foreground="Black" />
                            <TextBlock Text="{Binding [YEAR_RECOR]}" Foreground="Black" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="State Code: " Foreground="Black" />
                            <TextBlock Text="{Binding [STATE_CODE]}" Foreground="Black" />
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </Grid.Resources>

How I m binding my Xaml Defined infowindow to infowindow Property

at xaml.cs file

   public HpmsBaseEsriMap()
    {
        InitializeComponent();
        if (DesignerProperties.IsInDesignTool == false)
        {
            var dmv = ServiceLocator.Current.GetInstance<IHpmsBaseEsriMapViewModel>();
            dmv.HpmEditor = this.HpmsRoutesSelectionEditorNme;
            dmv.HpmMap = this.HpmEsriBaseMap;
            dmv.HpmInfoWindow = this.HpmInfoWindow;
            dmv.HpmMapTip = this.MyMapTip;
            dmv.BindingMap();
            DataContext = dmv;
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.