Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用mvvmlight将图钉绑定到bing地图?_C#_Windows 8_Windows 8.1_Mvvm Light_Bing Maps - Fatal编程技术网

C# 如何使用mvvmlight将图钉绑定到bing地图?

C# 如何使用mvvmlight将图钉绑定到bing地图?,c#,windows-8,windows-8.1,mvvm-light,bing-maps,C#,Windows 8,Windows 8.1,Mvvm Light,Bing Maps,我正在尝试使用MvvmLight工具包将我的自定义图钉模型绑定到bing地图控件。 这是我的密码 public class CustomPin { public int Id { get; set; } public double Latitude { get; set; } public double Longitude { get; set; } } public List<CustomPin> Pins = new List<Custo

我正在尝试使用MvvmLight工具包将我的自定义图钉模型绑定到bing地图控件。 这是我的密码

    public class CustomPin
{
    public int Id { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }
}


public List<CustomPin> Pins = new List<CustomPin>();


 private void BindLocation(List<Branch> branches)
    {
        for (int i = 0; i < branches.Count; i++)
        {
            CustomPin pin = new CustomPin();
            pin.Id = i;
            pin.Latitude = branches[i].Latitude;
            pin.Longitude = branches[i].Longitude;
            Pins.Add(pin);
        }
    }
公共类CustomPin
{
公共int Id{get;set;}
公共双纬度{get;set;}
公共双经度{get;set;}
}
public List Pins=new List();
专用位置(列出分支)
{
for(int i=0;i
我的XAML是:

       <bm:Map x:Name="Mymap"  ZoomLevel="1"  Credentials="xxxxx" Width="1366" Height="362">
        <bm:MapItemsControl x:Name="MapPins" ItemsSource="{Binding Pins}">
            <bm:Pushpin>
                <bm:MapLayer.Position>
                    <bm:Location Latitude="{Binding Path=Latitude}" Longitude="{Binding Path=Longitude}"></bm:Location>
                </bm:MapLayer.Position>
            </bm:Pushpin>
        </bm:MapItemsControl>
    </bm:Map>


运行此代码时,我看不到我的图钉。哪里出错了?

您正在将值分配给列表\u Pins,但您将其错误绑定为Pins。因此,将ItemSource设置为

ItemsSource="{Binding _Pins}"

希望有帮助。

对不起,我写错了。实际上,我正在对管脚进行pasing。@KaanYurdakök使用断点并检查是否可以获得纬度和经度值。根据你的代码,只有当你有合适的纬度和经度值时,你才能得到图钉。我有所有的坐标,但我想我不能绑定值。但是,当我尝试绑定一个坐标时,我可以得到结果,但对于多个绑定,它应该在您的情况下起作用。正如您所说,您只能绑定一个值,对吗?纬度还是经度?