Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to properly bind click event to a button in a ViewCell?

$
0
0

I have the following code snippet in an xaml file:

    <ListView x:Name="listView">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <Button Text="{Binding Name}" Clicked="ItemClicked" />
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>

Which corresponds to a code-behind Page class. However, when executed, I got the error: No method ItemClicked found on Xamarin.Forms.NavigationPage. Why is it mapped to a navigation page?

Also, in the ItemClicked event, how can I tell which data model in the list corresponds to the cell being clicked?

[Update: I am using Xamarin.Forms 1.1.0.6201]


Viewing all articles
Browse latest Browse all 91519

Trending Articles