Advertisement
smeacham

Untitled

May 19th, 2016
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 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.                 ((ListView)sender).SelectedItem = null;
  29.             };
  30. */
  31.             listView.ItemSelected += async (sender, e) =>
  32.             {
  33.                 if (e.SelectedItem == null) return;
  34.                 await DisplayAlert("Selected", e.SelectedItem.ToString(), "OK");
  35.                 ((ListView)sender).SelectedItem = null;
  36.             };
  37.  
  38.             this.Content = listView;
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement