Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityadeshpande/61b01d16e01f9afe872f41a694b88e69 to your computer and use it in GitHub Desktop.
Save adityadeshpande/61b01d16e01f9afe872f41a694b88e69 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using static MultiTapLVItems.DataFactory;
namespace MultiTapLVItems
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
SetContent();
}
private void SetContent()
{
//We dont want to select the entire Listview item so we disable the item selection here.
_myListView.ItemTapped += _myListView_ItemTapped;
//Populating Our Listview
DataFactory dataFactory = new DataFactory();
_myListView.ItemsSource = dataFactory.Users;
}
private void _myListView_ItemTapped(object sender, ItemTappedEventArgs e) => _myListView.SelectedItem = null;
private async void Call_Tapped(object sender, EventArgs e)
{
if (((sender as StackLayout).BindingContext is User _selectedUser))
{
await DisplayAlert("Call", String.Format("Do you want to call {0} on {1}?", _selectedUser.Name, _selectedUser.PhoneNumber), "Cancel", "Call");
}
}
private async void Msg_Tapped(object sender, EventArgs e)
{
if (((sender as StackLayout).BindingContext is User _selectedUser))
{
await DisplayAlert("Message", String.Format("Do you want to Message {0} on {1}?", _selectedUser.Name, _selectedUser.PhoneNumber), "Cancel", "Message");
}
}
private async void View_Tapped(object sender, EventArgs e)
{
if (((sender as StackLayout).BindingContext is User _selectedUser))
{
await DisplayAlert("View Profile", String.Format("The view profile page is unavailable so you cannot view {0}'s profile. Sorry! :P But their ID is {1}", _selectedUser.Name, _selectedUser.Id), "Okay");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment