WP7/Silverlight 超链接图片 [英] WP7/Silverlight Hyperlink Image

查看:20
本文介绍了WP7/Silverlight 超链接图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Silverlight 和 WP7 的新手.我一直在尝试通过使用 HyperlinkBut​​ton 并将其内容设置为图像来热链接图像.然而,这只会让我的图像消失.

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.

重现:

  1. 创建一个新的 Windows Phone 全景应用程序.
  2. 在 MainPage.xaml 上,将 Rectangle 替换为 Image,将源设置为 ApplicationIcon.png.
  3. 然后,用一个 HyperlinkBut​​ton 包围它.

<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.

感谢您的意见和建议.

推荐答案

这有点奇怪,因为您不能直接将 Image 作为控件的内容.该主题在此处a> 测试期间.

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 之前曾建议使用堆栈面板作为超链接的内容.这在当时确实有效,但由于某种原因目前似乎不起作用.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆