如何构建可点击图像。 [英] How to build a Clickable image.
本文介绍了如何构建可点击图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我构建可点击图像的方法。
我的xaml代码是
This is how I built a clickable image.
My xaml code is
< 按钮 高度 = " 150" 宽度 = " 150" HorizontalAlignment = " left" |
保证金 = " 12,6,0,0" 名称 = " Button1" VerticalAlignment = " Top" |
点击 = " Button1_Click" > |
< 图片 来源 = " 1.png" 名称 = " Image1" /> ; < / Button> |
<Button Height="150" Width="150" HorizontalAlignment="Left" |
Margin="12,6,0,0" Name="Button1" VerticalAlignment="Top" |
Click="Button1_Click"> |
<Image Source="1.png" Name="Image1" /> </Button> |
推荐答案
您可以通过向其添加MouseLeftButtonDown事件来使图像可点击:)
you can make an image clickable by adding MouseLeftButtonDown event to it :)
Xaml代码
<Image Name="image1" Stretch="Fill" Width="200" Height="100" MouseLeftButtonDown="image1_MouseLeftButtonDown" Source="Background.png" />
C#代码
private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// your code here
}
这篇关于如何构建可点击图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文