WPF中的图像映射 [英] image map in WPF

查看:183
本文介绍了WPF中的图像映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含图片的闪屏,当你点击它时会关闭,如:

I have a splashscreen that contains an image, and when you click it it closes, like:

<Canvas MouseLeftButtonUp="Image_MouseLeftButtonUp"> 
        <Canvas.Background>
            <ImageBrush ImageSource="pack://application:,,,/S3.ParametersUE.About;component/Resources/splash.jpg" />
        </Canvas.Background>
</Canvas>

现在,在图片中还有一些像http://www.site.com这样的文字

Now, in the image there's also some text like 'http://www.site.com'

WPF中是否有一种方法可以使这个部分可以点击,这样当点击它时,网页就会在浏览器中打开;所以与图像映射的行为基本相同?

Is there a way in WPF to make this part clickable, so that when it's clicked, the web page opens in the browser; so basically the same behavior as an image map?

推荐答案

你有可能从图像本身中移除文本,只是位置一个Button在画布中被设计为HyperLink?它可以让您更好地控制字体,文本和链接。例如,如果链接发生变化,您只需修改XAML而不是重新创建图像。

Any chance you can remove the text from the Image itself, and just position a Button styled as a HyperLink inside the Canvas? It would give you better control over the font, text, and link. For example, if the link ever changes you can just modify the XAML instead of recreating the image.

我能想到的唯一其他选择是跟踪MouseMove和MouseClick事件Canvas,如果鼠标位于Canvas的特定坐标内,则更改光标并处理click事件。

The only other alternative I can think of is tracking MouseMove and MouseClick events on the Canvas and if the mouse is within specific coordinates of the Canvas then change cursor and process the click event.

这篇关于WPF中的图像映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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