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));
}
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));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.