【发布时间】:2011-05-12 02:43:36
【问题描述】:
我正在使用 Bing 地图控件来显示一系列自定义图钉,代表不断移动和改变状态的对象。
使用数据绑定来更新对象的各种属性,但由于某些原因,这不适用于它们的位置。
我将地图绑定到 ObservableCollection,如下所示:
<UserControl.Resources>
<DataTemplate x:Key="PushpinTemplate">
<v:CustomPushpin />
</DataTemplate>
</UserControl.Resources>
...
<m:Map Name="map">
<m:MapItemsControl ItemTemplate="{StaticResource PushpinTemplate}" ItemsSource="{Binding Objects}" />
</m:Map>
...在 CustomPushpin 中:
<UserControl
...
m:MapLayer.Position="{Binding Location}" m:MapLayer.PositionOrigin="BottomCenter"
mc:Ignorable="d" d:DesignHeight="126" d:DesignWidth="85">
与所有其他属性一样,单个对象的位置是使用 INotifyPropertyChanged 实现的。
private Location _location;
public Location Location
{
get { return _location; }
set { _location = value; OnPropertyChanged("Location"); }
}
当地图移动时,无论是因为平移还是缩放,对象都会移动,但其他大小则不会。
我不太清楚我在这里做错了什么,或者是 Bing 地图控件有问题。
有什么想法吗?
【问题讨论】:
-
我遇到了同样的问题 :( 知道可能出了什么问题吗?
标签: wpf data-binding binding location bing-maps