I have a carouselview that works fine. all I want is when clicking an image in this carouselview if the image name is "monthly.jpg" then display an alert or navigate or ...
my xaml code is as falow:
<CarouselView x:Name="CV">
<CarouselView.ItemTemplate>
<DataTemplate>
<Frame WidthRequest="400">
<Frame
BackgroundColor="Red"
HasShadow="True"
HeightRequest="240"
WidthRequest="300"
HorizontalOptions="CenterAndExpand"
CornerRadius="10"
Margin="10"
Padding="0">
<Grid>
<StackLayout BackgroundColor="White">
<Image
Source="{Binding imgSource}"
Aspect="AspectFill"
ClassId="{Binding imgSource}"
HeightRequest="350">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="TapGestureRecognizer_OnTapped"
NumberOfTapsRequired="1">
</TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
....
and my code is:
private void TapGestureRecognizer_OnTapped(object sender, EventArgs e)
{
//string text = ((Image)sender).ClassId;
Image image = (Image)sender;
string imageString = image.ClassId;
if (imageString == "monthly.jpg")
{
DisplayAlert("Go Go", "Please Try Egain", "Continue");
}
}
but when I click an image nothing happen. where am I wrong?? do I worked with classID correctly or what?
Thanks for All answers and time you spend to solve my problem. anyway I changed my Tapping gesture to triggered at Grid and give my Grid Class ID. the program works now.
private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
var check = (Grid)sender;
string imageString = check.ClassId;
if (imageString == "daily check")
{
DisplayAlert("Day", "Please Try Egain", "Continue");
}