2016-07-13 3 views
0

특정 목록 항목을 클릭 할 때 값 (ID)을 다음 페이지로 전달할 수 없습니다.Xamarin.forms ListView 다음 페이지로 바로 가기

내 XAML 파일

<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> 

내 .CS 당신은 CommandParameter 아무것도에 바인딩이없는

async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) 
    { 
     ListView btn = (ListView)sender; 
     int clubid = (int)btn.CommandParameter; 

     await Navigation.PushAsync(new DetailedClub(clubid)); 
    } 

답변

1

파일. 더 간단한 방법은

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)); 
} 
+0

감사합니다! 그것은 작동합니다! :) –