-
StackOverflow 文件
-
Xamarin.Forms 教程
-
聯絡人 Picker - Xamarin Forms(Android 和 iOS)
-
MyPage.cs
using System;
using Xamarin.Forms;
namespace contact_picker
{
public class MyPage : ContentPage
{
Button button;
public MyPage ()
{
button = new Button {
Text = "choose contact"
};
button.Clicked += async (object sender, EventArgs e) => {
if (Device.OS == TargetPlatform.iOS) {
await Navigation.PushModalAsync (new ChooseContactPage ());
}
else if (Device.OS == TargetPlatform.Android)
{
MessagingCenter.Send (this, "android_choose_contact", "number1");
}
};
Content = new StackLayout {
Children = {
new Label { Text = "Hello ContentPage" },
button
}
};
}
protected override void OnSizeAllocated (double width, double height)
{
base.OnSizeAllocated (width, height);
MessagingCenter.Subscribe<MyPage, string> (this, "num_select", (sender, arg) => {
DisplayAlert ("contact", arg, "OK");
});
}
}
}