0

我在将 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>

和视图模型:

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

4

0 回答 0