Advertisement
smeacham

List View Selection

May 19th, 2016
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using Xamarin.Forms;
  8.  
  9. namespace ListViewDemoVS
  10. {
  11.     class MyContentPage : ContentPage
  12.     {
  13.         public MyContentPage()
  14.         {
  15.             List<String> items = new List<String>()
  16.             {
  17.                 "First", "Second", "Third"
  18.             };
  19.  
  20.             Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
  21.  
  22.             ListView listView = new ListView();
  23.             listView.ItemsSource = items;
  24.  
  25.             listView.ItemTapped += async (sender, e) =>
  26.             {
  27.                 await DisplayAlert("Tapped", e.Item.ToString(), "OK");
  28.             };
  29. /*
  30.             listView.ItemSelected += async (sender, e) =>
  31.             {
  32.                 await DisplayAlert("Selected", e.SelectedItem.ToString(), "OK");
  33.             };
  34. */
  35.             this.Content = listView;
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement