MainPage
<listView:SfListView x:Name="listView"ItemsSource="{Binding contactsinfo}">
<listView:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid x:Name="grid" RowSpacing="1">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.TapCommand, Source={x:Reference Name=listView}}"
CommandParameter="{Binding .}"/>
</Grid.GestureRecognizers>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</listView:SfListView.ItemTemplate>
</listView:SfListView>
ViewModel
public class ContactsViewModel : INotifyPropertyChanged
{
public Command<object> TapCommand { get; set; }
public ContactsViewModel()
{
TapCommand = new Command<object>(OnItemtapped);
}
private void OnItemtapped(object obj)
{
var newPage = new NewPage();
newPage.BindingContext = obj as Contacts;
App.Current.MainPage.Navigation.PushAsync(newPage);
}
} |
public partial class App : Application
{
public static ObservableCollection<Contacts> SelectedItems { get; set; }
public App()
{
InitializeComponent();
SelectedItems = new ObservableCollection<Contacts>();
MainPage = new NavigationPage(new Views.ListViewPage1());
}
... |
public partial class ListViewPage1 : ContentPage
{
public ListViewPage1()
{
InitializeComponent();
}
private async void listView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
App.SelectedItems.Add(e.ItemData as Contacts);
var nextPage = new ListViewPage2();
await Navigation.PushAsync(nextPage);
}
} |
public partial class ListViewPage4 : ContentPage
{
public ListViewPage4()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
listView.ItemsSource = App.SelectedItems;
}
} |