1 using System;
2 using System.Collections.ObjectModel;
3 using System.ComponentModel;
4 using System.Linq;
5 using System.Threading.Tasks;
6
7 using Xamarin.Forms;
8 using Xamarin.Forms.Xaml;
9
10 namespace XFPractice.Pages
11 {
12 [XamlCompilation(XamlCompilationOptions.Compile)]
13 public partial class ContactsPage : ContentPage
14 {
15 public ObservableCollection<string> Items { get; set; }
16
17 public ContactsPage()
18 {
19 InitializeComponent();
20
21 Title = "通讯录";
22
23 Items = new ObservableCollection<string>
24 {
25 "Item 1",
26 "Item 2",
27 "Item 3",
28 "Item 4",
29 "Item 5"
30 };
31
32 MyListView.ItemsSource = Items;
33
34 this.Appearing += ContactsPage_Appearing;
35 }
36
37 private void ContactsPage_Appearing(object sender, EventArgs e)
38 {
39 MyListView.HeightRequest = 36 * 5;
40 }
41
42 void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
43 {
44 if (e.Item == null)
45 return;
46 ((ListView)sender).SelectedItem = null;
47 }
48 }
49 }