WP7 / Silverlight超链接图像 [英] WP7/Silverlight Hyperlink Image
问题描述
我是Silverlight和WP7的新手。我一直在尝试使用HyperlinkButton热链接图像并将其内容设置为图像。但是,这只会让我的图像消失。
I am new to both Silverlight and WP7. I have been attempting to hotlink an image by using a HyperlinkButton and setting its content to an Image. However, this just makes my Image disappear.
重现:
- 创建一个新的Windows Phone全景应用。
- 在MainPage.xaml上用图像替换Rectangle,将源设置为ApplicationIcon.png。
- 然后用HyperlinkButton环绕它。
<HyperlinkButton NavigateUri="http://www.bing.com" TargetName="_blank">
<Image Source="ApplicationIcon.png"/>
</HyperlinkButton>
我尝试过很多属性,对我来说没什么用。这两个项目都是相互依赖的。在WP7中这可能吗?它是一个外部URI。我搜索了文档并发现没有任何帮助。
I have tried numerous properties and nothing works for me. Both items work interdependently. Is this possible in WP7? It is an external URI. I have search for documentation and found nothing that's helped.
您的意见和建议表示赞赏。
Your comments and suggestions are appreciated.
推荐答案
这有点奇怪,因为你无法直接将Image作为控件的内容放置。该主题探讨了此处测试期间。
This is a bit of an oddity in that you can't directly place an Image as the control's content. The topic was explored here during beta.
Peter Torr先前建议使用stackpanel作为超链接的内容。这在当时确实有效,但由于某种原因目前似乎没有工作。
Peter Torr's had previously suggested using a stackpanel as the hyperlink's content. This did work at the time, but does not appear to be working at the moment for some reason.
据说,Richard Woo确定了一个可以使用的工作超链接背景属性。我确认这仍然有效如下:
With that said, Richard Woo identified a work around which was to use the hyperlinks background property. I confirmed this still works as follows:
<HyperlinkButton Height="310" HorizontalAlignment="Left" Margin="206,202,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="200" >
<HyperlinkButton.Background>
<ImageBrush ImageSource="SplashScreenImage.jpg"/>
</HyperlinkButton.Background>
</HyperlinkButton>
作为一个需要在建议论坛或连接上查看的问题,可能值得提出这个问题。
It may be worth raising this as an issue to be looked into on the suggestions forum or connect.
就超链接的替代品来说,Matt的图像和手势选项看起来可行。您也可以使用Button并在Blend中重新设置它的外观。
As far as alternatives to hyperlink go, Matt's option with an Image and gesture looks workable. You could also use a Button and retemplate it's appearance in Blend.
这篇关于WP7 / Silverlight超链接图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!