1
       <DataTemplate x:Key="pushpinSelector">
        <my:Pushpin Location="{Binding Location}" CacheMode="BitmapCache">
            <my:Pushpin.Template>
                <ControlTemplate>
                    <clusterer:PushpinTemplateSelector Content="{Binding}">
                        <clusterer:PushpinTemplateSelector.ClusterTemplate>
                            <DataTemplate>
                                <Grid VerticalAlignment="Center" HorizontalAlignment="Center" CacheMode="BitmapCache">
                                    <Image Source="{Binding ImagePath}" Width="50" Height="50"></Image>
                                    <TextBlock Foreground="Red" Text="{Binding ClusterCount}" HorizontalAlignment="Center" VerticalAlignment="Top"></TextBlock>
                                </Grid>
                            </DataTemplate>
                        </clusterer:PushpinTemplateSelector.ClusterTemplate>                            
                    </clusterer:PushpinTemplateSelector>
                </ControlTemplate>
            </my:Pushpin.Template>
        </my:Pushpin>
    </DataTemplate>

var doc = XDocument.Load("PushpinClusteringExample;component/jugglingclubs.xml");

        var pins = doc.Descendants("club")
            // get clubs with coordinates
                      .Where(club => club.Descendants("coordinates").Any())
                      .Select(el => new
                      {
                          lat = double.Parse(el.Descendants("latitude").Single().Value),
                          lon = double.Parse(el.Descendants("longitude").Single().Value),
                          name = el.Descendants("name").Single().Value,
                          country = el.Descendants("country").Single().Value,
                          //address = el.Descendants("address").Single().Value
                      })
            // verify the coordinates are sensible!
                      .Where(coord => coord.lat < 90 && coord.lat > -90 && coord.lon < 90 && coord.lon > -90)
            // create a pushpin for each club
                      .Select(i => new MyGeoObject()
                      {
                          Coordinate = new GeoCoordinate(i.lat, i.lon),
                          Name = i.name,
                          Country = i.country,                              
                          //Address = i.address
                      }).ToList();
        for (int j = 0; j < pins.Count; j++)
        {
            if (pins[j].Country == "United Kingdom")
            {

                List<ImageData> dataSource = new List<ImageData>()
                { 
                    new ImageData(){ImagePath="/MapPin.png"},                    
                };
                //Icon = new BitmapImage(new Uri("/MapPin.png", UriKind.Relative));
                DataContext = this;
            }
            else
            {
                List<ImageData> dataSource = new List<ImageData>() 
                { 
                new ImageData(){ImagePath="/DrawingPin1_Blue.png"},
                };
                //Icon = new BitmapImage(new Uri("/DrawingPin1_Blue.png", UriKind.Relative));
                DataContext = this;
            }                
        }

       var clusterer = new PushpinClusterer<MyGeoObject>(map1, pins, 50);
       pushPinModelsLayer.DataContext = clusterer;

ImagePath を Image コントロール ソースにバインドしようとしていますが、Image がバインドされません。私がさらに進むのを手伝ってください

ありがとう

4

0 に答える 0