標籤:des c style class blog code
(1)連絡人(Manifest 擷取許可權)
1)擷取連絡人
擷取連絡人的方式有兩種
A. ContactPicker
ContactPicker 也就是直接開啟一個系統的選擇連絡人介面,讓使用者選擇,可設定單選或多選:
var contactPicker = new ContactPicker();contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber);//Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactsAsync();Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactAsync();if( contact != null ){ MessageDialog dialog = new MessageDialog(string.Format("Phone Number: {0}", contact.Phones.First().Number), contact.DisplayName); await dialog.ShowAsync();}
必須設定唯一的一個 ContactFieldType。
B. ContactManager
可通過 ContactManager API 直接搜尋某連絡人:
ContactStore contactStore = await ContactManager.RequestStoreAsync();var list = await contactStore.FindContactsAsync(searchTextBox.Text.Trim());
擷取的連絡人清單為唯讀。
2)與連絡人聯絡
可直接向連絡人撥打到電話、傳送簡訊、發送郵件:
PhoneCallManager.ShowPhoneCallUI("15911111111", "Some");ChatMessage message = new ChatMessage();message.Recipients.Add("15911111111");message.Body = "Test.";await ChatMessageManager.ShowComposeSmsMessageAsync(message);EmailMessage email = new EmailMessage();email.To.Add(new EmailRecipient("[email protected]"));email.Body = "Test.";await EmailManager.ShowComposeNewEmailAsync(email);
(2)日曆
1)直接開啟系統的日曆應用
比如開啟日曆主介面:
await AppointmentManager.ShowTimeFrameAsync(DateTimeOffset.Now, TimeSpan.FromHours(1));
2)API 方式
比如建立一個日曆事件:
Appointment appointment = new Appointment();appointment.Subject = "";appointment.StartTime = DateTimeOffset.Now;//...await AppointmentManager.ShowAddAppointmentAsync(appointment, new Rect());
更多 API :連結