【问题标题】:UWP Map's center not updated when moving移动时 UWP 地图的中心未更新
【发布时间】:2016-07-28 06:39:44
【问题描述】:

我已经绑定了MapControl 的中心,但是当我移动时地图没有更新。

<maps:MapControl BusinessLandmarksVisible="False"
                 LandmarksVisible="False"
                 ColorScheme="Light"
                 DesiredPitch="50"
                 PedestrianFeaturesVisible="False"
                 TrafficFlowVisible="False"
                 TransitFeaturesVisible="False"
                 ZoomLevel="20"
                 RelativePanel.AlignTopWithPanel="True"
                 RelativePanel.AlignBottomWithPanel="True"
                 RelativePanel.AlignLeftWithPanel="True"
                 RelativePanel.AlignRightWithPanel="True"
                 Center="{Binding CurrentGeoposition.Coordinate.Point, Mode=TwoWay}"
                 MapServiceToken="{Binding MapServiceToken, Mode=OneTime}"
                 x:Name="MapControl"/>

唯一的解决方案是让它成为双向绑定,但由于它绑定到 Geoposition,我被这样的错误淹没了:

Error: Cannot save value from target back to source. BindingExpression: Path='CurrentGeoposition.Coordinate.Point' DataItem='MyNamespace.ViewModels.GameManagerViewModel'; target element is 'Windows.UI.Xaml.Controls.Maps.MapControl' (Name='MapControl'); target property is 'Center' (type 'Geopoint').

有没有办法让这项工作没有所有错误,但没有代码隐藏?

【问题讨论】:

    标签: uwp windows-10-universal uwp-xaml uwp-maps


    【解决方案1】:

    在你的 XAML 中试试这个:

    Center="{Binding MapCenter, Mode=TwoWay}"
    

    这在你的 viewModel 中:

    public Geopoint MapCenter {
        get;
        set; }
    

    如果这没有帮助,您可以粘贴您的 viewModel 以及您的 XAML 吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-08
      • 2018-06-21
      • 1970-01-01
      相关资源
      最近更新 更多