Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following XAML view, and when the Item is tapped I want to navigate to a detail page:

 <ListView x:Name="ProductsList" ItemsSource="{Binding Products}"
                  HasUnevenRows="True"
                  SelectedItem="{Binding SelectedProduct}"
                  ItemTapped="ProductItem_OnTapped">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <local1:ProductTemplate />
                </DataTemplate>
            </ListView.ItemTemplate>
  </ListView>

This is the handler:

public async void ProductItem_OnTapped(ItemTappedEventArgs e)
{
    var productDetailVM = new ProductDetailViewModel(SelectedProduct);
    var productDetailView = new ProductDetail();
    productDetailView.BindingContext = productDetailVM;

    await Application.Current.MainPage.Navigation.PushAsync(productDetailView);
}

The error I am getting is this:

EventHandler "ProductItem_OnTapped" with correct signature not found in type "ProductTest.MainPage".

question from:https://stackoverflow.com/questions/66055538/correct-signature-not-found-for-itemtapped-event-handler

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
362 views
Welcome To Ask or Share your Answers For Others

1 Answer

ProductItem_OnTapped should be declared with a first sender parameter of type object, also make sure it is defined in the code-behind (MainPage.xaml.cs in this case).

public async void ProductItem_OnTapped(object sender, ItemTappedEventArgs e)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...