neil.moore

Map Tip Binding

Discussion created by neil.moore on Apr 9, 2014
Latest reply on Apr 10, 2014 by akajanus-esristaff
Hi All,

I know there are a couple of other threads on this but I've been through them and while my example seems to be similar to the suggested solutions in those, it still hasn't resolved my issue.

The problem I have is that the map tips appear with no text in them.  I have included a screen grab to illustrate the issue.

[ATTACH=CONFIG]32944[/ATTACH]

The problem seems to be that the DataContext is null and I'm not sure why this would be.

I have included my code below.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpftoolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
        xmlns:local="clr-namespace:WpfApplication5"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009" x:Class="WpfApplication5.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <local:TestConverter x:Key="Conv" />
        <local:VM x:Key="VM" />
        <esri:MarkerSymbol x:Key="SupplierMarker" >
            <esri:MarkerSymbol.ControlTemplate>
                <ControlTemplate>
                    <Ellipse Width="15" Height="15" 
                            Fill="Gold" Stroke="Black" 
                            Margin="-7.5 -7.5 0 0" />
                </ControlTemplate>
            </esri:MarkerSymbol.ControlTemplate>
        </esri:MarkerSymbol>

    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource VM}}">
        <esri:Map WrapAround="True">
            <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
            <esri:GraphicsLayer>
                <esri:GraphicsLayer.GraphicsSource>
                    <esri:PointDataSource ItemsSource="{Binding Path=SList, Source={StaticResource VM}}"
                                          XCoordinateBinding="{Binding Long}"
                                          YCoordinateBinding="{Binding Lat}" />
                </esri:GraphicsLayer.GraphicsSource>
                <esri:GraphicsLayer.Renderer>
                    <esri:SimpleRenderer Symbol="{StaticResource SupplierMarker}" />
                </esri:GraphicsLayer.Renderer>
                <esri:GraphicsLayer.MapTip>
                    <Border Padding="4,2" Background="Black">
                        <StackPanel>
                            <TextBlock Foreground="White">
                            <Run Text="{Binding [Name]}" />
                            </TextBlock>
                        </StackPanel>
                    </Border>
                </esri:GraphicsLayer.MapTip>
            </esri:GraphicsLayer>

        </esri:Map>
    </Grid>
</Window>


    class VM : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            var eventToFire = PropertyChanged;
            if (eventToFire == null)
                return;

            eventToFire(this, new PropertyChangedEventArgs(propertyName));
        }

        private List<Pin> _SList;
        public List<Pin> SList
        {
            get
            {
                return _SList;
            }
            set
            {
                if (_SList != value)
                {
                    _SList = value;
                    OnPropertyChanged("SList");
                }
            }
        }


        public VM()
        {
            SList = new List<Pin>()
                {
                    new Pin() { Name = "Somewhere" , Lat = 52.4790684, Long = -0.9117778 },
                    new Pin() { Name = "Test", Lat = 52.4803692, Long = -0.9232606 }
                };
        }

    }


If anyone could shed any light on this I would be really grateful.

Many thanks in advance,

Neil.

Attachments

Outcomes