【发布时间】:2017-01-12 00:50:30
【问题描述】:
我想根据我的 ObservableCollection 显示图钉:
XAML:
<Grid>
<my:MapControl>
<my:MapItemsControl ItemsSource="{Binding Users}">
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:MapIcon Title="{Binding Name}" Location="{Binding Location}"></my:MapIcon>
</DataTemplate>
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
</my:MapControl>
</Grid>
这里查看模型: 公共 ObservableCollection 用户 { 获取;放; }
public MapPageViewModel()
{
Users = new ObservableCollection<User>()
{
new User
{
Id = 1,
Name = "Chris",
Location = new Location { Latitude = 52.645, Longitude = 13.431}
},
new User
{
Id = 1,
Name = "Brown",
Location = new Location { Latitude = 52.15, Longitude = 12.431}
}
};
}
在启动程序时尝试显示地图图标时出现错误无论如何行中有错误
Title={绑定名称}
即使 User 模型具有属性 Name 并且我将 ItemSource 设置为 Users,它也无法解析 Name。
有人知道如何解决这个问题吗?
【问题讨论】:
标签: c# xaml windows-phone-8.1 bing-maps