Reputation: 153
I am not able to pass the value(id) to the next page when I clicked on the specific list items.
My Xaml file
<ListView x:Name="Clublistview" HasUnevenRows="true" ItemSelected="OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="50">
<StackLayout BackgroundColor="White"
Orientation="Vertical">
<StackLayout Orientation="Horizontal">
<Image Source="{Binding Logo}" IsVisible="true" WidthRequest="50" HeightRequest="50"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My .CS file
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
ListView btn = (ListView)sender;
int clubid = (int)btn.CommandParameter;
await Navigation.PushAsync(new DetailedClub(clubid));
}
Upvotes: 0
Views: 5142
Reputation: 89082
You don't have CommandParameter bound to anything. A simpler approach would be
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
ListView lv = (ListView)sender;
// this assumes your List is bound to a List<Club>
Club club = (Club) lv.SelectedItem;
// assuiming Club has an Id property
await Navigation.PushAsync(new DetailedClub(club.Id));
}
Upvotes: 2