How to get Information from ViewCell components for a Tapped event?

Hello together,

I'm new to Xamarin Forms and I did not found a solution for my problem so far.
Right now I create a ObservableCollection to fill my Listview with Data.

The XAML looks like this:

        <ListView x:Name="Test" SeparatorVisibility="Default" IsPullToRefreshEnabled ="True" RefreshCommand="{Binding ReloadCommand}"
          IsRefreshing="{Binding IsBusy, Mode=OneWay}" RowHeight="55" SeparatorColor="Black">

                    <ViewCell Tapped="ViewCell_Tapped">
                            <Grid Padding="5">
                                    <RowDefinition Height="20"></RowDefinition>
                                    <RowDefinition Height="20"></RowDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>

                                <Label  Grid.Row="0" Grid.Column="0" Text="{Binding ArticleName_Number}" TextColor="Black" LineBreakMode="TailTruncation"></Label>
                                <Label Grid.Row="1" Grid.Column="0" Text="{Binding ProductId}" Font="Small"  TextColor="Gray" LineBreakMode="TailTruncation"></Label>
                                <Label Grid.Row="0" Grid.Column="1" Text="{Binding Status}" TextColor="{Binding Color}" HorizontalTextAlignment="End"/>
                                <Label Grid.Row="1" Grid.Column="1" Text="{Binding ProductionEnd}" TextColor="{Binding Color}" HorizontalTextAlignment="End"/>



And the Constructor:

            public TestPage()
                        ListViewItems = new ObservableCollection<ProductionList> ();
                        BindingContext = this;
                        Test.ItemsSource = ListViewItems;

My goal is it, to use the "Tapped="ViewCell_Tapped" to call a constructor for the next NavigationPage with the Value of Label.Text or the "real" Value from the object that was bound to that ViewCell. If i tapp the ViewCell it should call something like:

       await this.Navigation.PushAsync(new Nextpage(1));

Where the 1 should be of course variable depending on the tapped ViewCell.


I create a Product overview for different Products inside a Listview.
When i tapp one, I want to navigate to a Detailed page for that specific entry.


How do I get the Product Id to the tapped Event?

I hope someone can help me with that (probably totally dumb) question. :smiley:

Best Answer


  • Thank you so much! That works perfectly fine.
    Is there a documentation for that topic?
    I didn't know about the ItemTappedEventArgs e.
    Well, that's probably due to my lack of experience. :neutral:

Sign In or Register to comment.