我遇到了将LocationCollection绑定到MapPolyline位置属性的问题。 这是我的XAML代码的片段:
<bm:Map x:Name="map" Credentials="MY_KEY" Grid.Column="1">
<bm:Map.Children>
<bm:MapItemsControl ItemTemplate="{StaticResource PushPinTemplate}" ItemsSource="{Binding HostsList}"/>
</bm:Map.Children>
<bm:Map.ShapeLayers>
<bm:MapShapeLayer>
<bm:MapShapeLayer.Shapes>
<bm:MapPolyline Locations="{Binding PathLocations}" Color="Red" Width="5" />
</bm:MapShapeLayer.Shapes>
</bm:MapShapeLayer>
</bm:Map.ShapeLayers>
</bm:Map>
和ViewModel:
public ObservableCollection<HostDetailsModel> HostsList { get; set; }
private LocationCollection pathLocations;
public LocationCollection PathLocations
{
get { return pathLocations; }
set { SetProperty(ref pathLocations, value); }
}
public TracePageViewModel()
{
HostsList = new ObservableCollection<HostDetailsModel>();
PathLocations = new LocationCollection();
....
}
....
当我启动应用程序时,我的页面构造函数在线上有一个XamlParseException
this.InitializeComponent();
没有<bm:Map.ShapeLayers>...</bm:Map.ShapeLayers>
之间的内容一切都很好。
图钉正确绑定。
有谁知道发生了什么?
提前谢谢。
这是例外的StackTrace,也许有一些重要的东西。
StackTrace at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)\r\n at AppName.Views.TracePage.InitializeComponent() in c:\\Visual Studio 2012\\Projects\\AppName\\obj\\x86\\Debug\\Views\\TracePage.g.i.cs:line 44\r\n at AppName.Views.TracePage..ctor() in c:\\Visual Studio 2012\\Projects\\AppName\\Views\\TracePage.xaml.cs:line 26\r\n at AppName.AppName_XamlTypeInfo.XamlTypeInfoProvider.Activate_40_TracePage() in c:\\Visual Studio 2012\\Projects\\AppName\\obj\\x86\\Debug\\XamlTypeInfo.g.cs:line 177\r\n at AppName.AppName_XamlTypeInfo.XamlUserType.ActivateInstance() in c:\\Visual Studio 2012\\Projects\\AppName\\obj\\x86\\Debug\\XamlTypeInfo.g.cs:line 3698" string