image map in WPF

烈酒焚心 提交于 2019-12-13 00:28:45

问题


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>

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

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/5405228/image-map-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!