我有一张图片A这张图片当我单击它时它会显示图片C,如果我双击图片则会显示图片D.
以下是我在xaml中的代码:
<Image Source="pictureA.JPG"
VerticalOptions="Start"
HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped" />
</Image.GestureRecognizers>
</Image>
以下是我在cs中的代码:
int tapCount;
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{
var imageSender = (Image)sender;
if (tapCount == 1)
{
imageSender.Source = "pictureC.png";
}
else if (tapCount == 2)
{
imageSender.Source = "pictureD.JPG";
}
}
但是上面的代码不起作用,任何人都可以分享我的想法吗?