数据绑定 – 与Windows Phone 8的Map API扩展绑定
发布时间:2020-12-14 05:27:43 所属栏目:Windows 来源:网络整理
导读:我正在尝试使用 windows phone toolkit的map api扩展名进行数据绑定.我正在做 : maps:Map x:Name="Map" Center="47.6,-122.3" ZoomLevel="12" maptk:MapExtensions.Children maptk:MapItemsControl ItemsSource="{Binding PositionList}" maptk:MapItemsCon
|
我正在尝试使用
windows phone toolkit的map api扩展名进行数据绑定.我正在做 :
<maps:Map x:Name="Map" Center="47.6,-122.3" ZoomLevel="12">
<maptk:MapExtensions.Children>
<maptk:MapItemsControl ItemsSource="{Binding PositionList}">
<maptk:MapItemsControl.ItemTemplate>
<DataTemplate>
<maptk:Pushpin GeoCoordinate="{Binding}" />
</DataTemplate>
</maptk:MapItemsControl.ItemTemplate>
</maptk:MapItemsControl>
</maptk:MapExtensions.Children>
</maps:Map>
我的代码背后: public partial class MainPage : PhoneApplicationPage,INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null)
PropertyChanged(this,new PropertyChangedEventArgs(name));
}
private bool NotifyPropertyChanged<T>(ref T variable,T valeur,[CallerMemberName] string name= null)
{
if (object.Equals(variable,valeur)) return false;
variable = valeur;
NotifyPropertyChanged(name);
return true;
}
private IEnumerable<GeoCoordinate> positionList;
public IEnumerable<GeoCoordinate> PositionList
{
get { return positionList; }
set { NotifyPropertyChanged(ref positionList,value); }
}
public MainPage()
{
InitializeComponent();
PositionList = new List<GeoCoordinate>
{
new GeoCoordinate(47.6050338745117,-122.334243774414),new GeoCoordinate(47.6045697927475,-122.329885661602),new GeoCoordinate(47.605712890625,-122.330268859863),new GeoCoordinate(47.6015319824219,-122.335113525391),new GeoCoordinate(47.6056594848633,-122.334243774414)
};
DataContext = this;
}
}
但我在地图上看不到任何图钉:( 我究竟做错了什么 ? 请注意,如果我在代码隐藏文件中使用它,它正在工作 MapExtensions.GetChildren(Map).OfType<MapItemsControl>().First().ItemsSource = PositionList; 在此先感谢您的帮助, 最好的祝福 解决方法
MapItemsControl派生自DependencyObject,而不是FrameworkElement,因此DataContext不会传播.长篇故事…你不能从XAML绑定MapItemsControl的数据,除非你有办法设置Binding的Source属性.
如果RelativeSource的FindAncestor模式在手机上运行,??可能可以解决这个问题,但显然没有.这使我们无法在代码中创建绑定,或者(更现实地)在代码中设置ItemsSource. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- pycharm提示错误Server's certificate is not trusted解
- iis-7 – 在IIS 7.5上为使用Windows身份验证的ASHX处理程序
- DLL – 在Firefox扩展中使用Firebreath生成的插件?
- 解决 Win7 远程桌面 已停止工作的问题
- 部署 – 为x86 windows系统捆绑的JavaFX exe
- window10下git和github连接的解决方法
- MPI与Microsoft WCF对比Microsoft TPL
- windows-server-2008-r2 – 您多久重启一次利用率很高的Win
- Windows运行时 – 在Windows Store应用程序上实现下划线超链
- Windows Azure网站的SSL证书
推荐文章
站长推荐
热点阅读
