带有图像的 WP7 Bing 地图图钉模板不显示
我的最终目标是在 WP7 应用程序的 Bing 地图上添加带有自定义图像的图钉。我创建了一个控件模板和一个带有图钉的地图。现在,我可以显示默认图钉,但当我尝试对其进行模板化时,没有任何显示。这就是我现在所拥有的:
<phone:PhoneApplicationPage.Resources>
<ControlTemplate x:Key="PushpinControlTemplate" TargetType="my:Pushpin">
<Image Source="/Images/Pins/pin.png" />
</ControlTemplate>
</phone:PhoneApplicationPage.Resources>
<my:Map Name="mapMain" CredentialsProvider="CredKey">
<my:Pushpin/>
</my:Map>
如果我应用 PushpinControl 模板,则不会显示任何内容:
<my:Pushpin Template="{StaticResource BoaPushpinControlTemplate}" />
如果我删除模板,它会显示默认的黑色形状。
我的模板一定是错误的,但我不知道问题出在哪里。我可以在 ControlTemplate 中没有图像吗?
My ultimate goal is to have pushpins with custom images on a Bing Map in a WP7 app. I have created a control template and a map with a pushpin. Right now, I can get the default pushpins to show up, but nothing shows when I try to template it. Here's what I have right now:
<phone:PhoneApplicationPage.Resources>
<ControlTemplate x:Key="PushpinControlTemplate" TargetType="my:Pushpin">
<Image Source="/Images/Pins/pin.png" />
</ControlTemplate>
</phone:PhoneApplicationPage.Resources>
<my:Map Name="mapMain" CredentialsProvider="CredKey">
<my:Pushpin/>
</my:Map>
If I apply the PushpinControl template nothing shows up:
<my:Pushpin Template="{StaticResource BoaPushpinControlTemplate}" />
If I remove the template, it shows the default black shape.
I must be doing my template incorrectly, but I don't know what the problem is. Can I not have an image in the ControlTemplate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有在地图上使用 ItemSource 绑定,则使用简单的内容控制方法
或者如果您动态填充图钉,请使用以下方法
If you arent using ItemSource binding on the Map then use simple content control approach
Or if you dynamically populating the push-pins use the below approach
尽管这个帖子有点旧,我还是要发布我的建议:
尝试这个链接 使用图钉,它对我有用(创建新样式并在图钉声明中使用它)
(App.xaml,不要忘记命名空间! )
(在 xaml 中有地图)
如果这不起作用,请检查图片的构建操作是否设置为内容。
我花了一段时间才弄清楚这一点,所以我希望我可以帮助别人,尽管这个线程已经很旧了。 ;)
Even though this thread is a little bit old I'm going to post my suggestion:
Try out this link Working with Pushpins, it is working for me (create a new style and use it in pushpin declaration)
(App.xaml, do not forget the namespace!)
(in the xaml there the map is)
If this isn't working check if the Build Action of your picture is set to content.
Took me a while to figure this out, so i hope i could help someone, despite the fact that this thread is old. ;)