C# Windows Phone 8.1中MapControl Center属性的数据绑定
我正在开发一个WindowsPhone8.1(winRT)应用程序,它带有MVVM灯和一个使用MapControl的PCL。 我对MapControl Center属性的绑定有问题。 在应用程序初始化时,将在ViewModel中设置属性,并且贴图正确居中 但是,当我更新ViewModel中的值时,贴图不会重新居中,但如果我将该值绑定到文本块,它将正确更新 XAML:C# Windows Phone 8.1中MapControl Center属性的数据绑定,c#,xaml,mvvm,windows-phone-8.1,bing-maps,C#,Xaml,Mvvm,Windows Phone 8.1,Bing Maps,我正在开发一个WindowsPhone8.1(winRT)应用程序,它带有MVVM灯和一个使用MapControl的PCL。 我对MapControl Center属性的绑定有问题。 在应用程序初始化时,将在ViewModel中设置属性,并且贴图正确居中 但是,当我更新ViewModel中的值时,贴图不会重新居中,但如果我将该值绑定到文本块,它将正确更新 XAML: <Maps:MapControl BorderThickness="2" BorderBrush="Black"
<Maps:MapControl BorderThickness="2" BorderBrush="Black"
x:Name="Map"
HorizontalAlignment="Right" Margin="0,45,0,0"
VerticalAlignment="Top"
Height="595" Width="400"
ZoomLevel="10"
LandmarksVisible = "False"
TrafficFlowVisible = "False"
PedestrianFeaturesVisible = "False"
Center="{Binding Path=ViewStoreModel.CenterPosition, Mode=OneWay, Converter={StaticResource NormalizedAnchorPointConverter}}"
MapServiceToken="{StaticResource MapServiceTokenString}">
<Maps:MapItemsControl x:Name="MapIcons" ItemsSource="{Binding ViewStoreModel.ListStoreSearch}" >
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate x:Name="Temp" >
<StackPanel Tapped="Image_Tapped" x:Name="MyStack" Maps:MapControl.Location="{Binding store_position, Converter={StaticResource GeoPointConvertCenter}}">
<Image x:Name="PinsImage" Source="ms-appx:///Assets/map-pin-button.png" />
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>
属性中心是一个类型地质点,因此我使用转换器从自定义类位置转换它。
中心是一个依赖属性,因此它应该是可绑定的
谢谢您的帮助。是否尝试删除“路径”属性并将其直接绑定到ViewModel
<Maps:MapControl Center="{Binding ViewStoreModel.CenterPosition, Mode=OneWay, Converter={StaticResource NormalizedAnchorPointConverter}}"/>
是否尝试删除“Path”属性并将其直接绑定到ViewModel
<Maps:MapControl Center="{Binding ViewStoreModel.CenterPosition, Mode=OneWay, Converter={StaticResource NormalizedAnchorPointConverter}}"/>
是否尝试删除“Path”属性并将其直接绑定到ViewModel
<Maps:MapControl Center="{Binding ViewStoreModel.CenterPosition, Mode=OneWay, Converter={StaticResource NormalizedAnchorPointConverter}}"/>
是否尝试删除“Path”属性并将其直接绑定到ViewModel
<Maps:MapControl Center="{Binding ViewStoreModel.CenterPosition, Mode=OneWay, Converter={StaticResource NormalizedAnchorPointConverter}}"/>
我发现MapControl中有一些bug。 问题来自绑定模式。OneWay似乎像OneTime一样工作(仅在init时)。 如果我说双向的话,它会工作,但是地图会不断地更新ViewModel 作为一种解决方法,我指定当XAML必须更新源代码时,我们必须告诉显式性 代码:
我发现MapControl中有一些bug。 问题来自绑定模式。OneWay似乎像OneTime一样工作(仅在init时)。 如果我说双向的话,它会工作,但是地图会不断地更新ViewModel 作为一种解决方法,我指定当XAML必须更新源代码时,我们必须告诉显式性 代码:
我发现MapControl中有一些bug。 问题来自绑定模式。OneWay似乎像OneTime一样工作(仅在init时)。 如果我说双向的话,它会工作,但是地图会不断地更新ViewModel 作为一种解决方法,我指定当XAML必须更新源代码时,我们必须告诉显式性 代码:
我发现MapControl中有一些bug。 问题来自绑定模式。OneWay似乎像OneTime一样工作(仅在init时)。 如果我说双向的话,它会工作,但是地图会不断地更新ViewModel 作为一种解决方法,我指定当XAML必须更新源代码时,我们必须告诉显式性 代码:
我们使用了一种不同的方法。
我们使用了DataContext的
PropertyChanged
事件-在处理程序中,我们检查e.PropertyName
是否等于CurrentLocation
,如果等于,我调用NearbySitesMap.SetView(CurrentLocation,ZoomLevel,NearbySitesMap.Heading)代码>
这样,当CurrentLocation更改时,地图将获得一个漂亮而平滑的动画到新位置。我们使用了一种不同的方法。
我们使用了DataContext的PropertyChanged
事件-在处理程序中,我们检查e.PropertyName
是否等于CurrentLocation
,如果等于,我调用NearbySitesMap.SetView(CurrentLocation,ZoomLevel,NearbySitesMap.Heading)代码>
这样,当CurrentLocation更改时,地图将获得一个漂亮而平滑的动画到新位置。我们使用了一种不同的方法。
我们使用了DataContext的PropertyChanged
事件-在处理程序中,我们检查e.PropertyName
是否等于CurrentLocation
,如果等于,我调用NearbySitesMap.SetView(CurrentLocation,ZoomLevel,NearbySitesMap.Heading)代码>
这样,当CurrentLocation更改时,地图将获得一个漂亮而平滑的动画到新位置。我们使用了一种不同的方法。
我们使用了DataContext的PropertyChanged
事件-在处理程序中,我们检查e.PropertyName
是否等于CurrentLocation
,如果等于,我调用NearbySitesMap.SetView(CurrentLocation,ZoomLevel,NearbySitesMap.Heading)代码>
这样,当CurrentLocation发生更改时,地图会在新位置获得一个漂亮而平滑的动画。效果良好。。除了propertychanged,您还可以执行附加属性并使用它绑定CurrentLocation…效果很好。。除了propertychanged,您还可以执行附加属性并使用它绑定CurrentLocation…效果很好。。除了propertychanged,您还可以执行附加属性并使用它绑定CurrentLocation…效果很好。。除了propertychanged,您还可以执行附加属性并使用该属性绑定CurrentLocation。。。