Operations related to Windows Phone 7 phone book

Source: Internet
Author: User

Take a moment to learn WP7. The learning progress is slow due to poor C # basics and work reasons.

Slow down. Slow down. Haha ....

These two methods are used to learn the programming of the phone book in WP7, mainly to read the phone book and the operating phone. However, it is found that the operation on the phone book in WP7 is too restrictive and unsuitable.

The following code reads the phone book and adds a new phone book through savecontacttask. There is no way to edit or delete code on the Internet...

In the following code, the compilation fails. Although it does not affect the function, I still want to know why it doesn't work. continue later.

# DEFINE _ simple_output_pb_using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using Microsoft. phone. userdata; // using system. dusing Microsoft. phone. tasks; namespace phonebookop {public partial class mainpage: phoneapplicationpage {// constructor public mainpage () {initializecomponent () ;}# if (_ simple_output_pb _)
// Note that the following two functions are different. At that time, I did not pay attention to the differences in size. Void contactssearchcompleted (Object sender, contactssearcheventargs e) {foreach (VAR varresult in E. results) {system. diagnostics. debug. writeline ("name:" + varresult. displayname + "phone number:" + varresult. phonenumbers. firstordefault (); listbox1.items. add (varresult. displayname + "" + varresult. phonenumbers. firstordefault () ;}} private void contactssearchcompleted (Object sender, contactsse Archeventargs e) {foreach (contact contactresult in E. results) {string name = contactresult. displayname; contactphonenumber phonenumber = contactresult. phonenumbers. firstordefault (); string strphone = string. empty; If (null! = Phonenumber) {strphone = phonenumber. phonenumber;}/* contactaddress address = contactresult. Addresses. firstordefault (); string straddr = string. Empty; If (null! = Address) {straddr = address. physicaladdress. addressline1; // This row is not compiled through system. device cannot be using} */contactemailaddress emailaddress = contactresult. emailaddresses. firstordefault (); string stremail = string. empty; If (null! = Emailaddress) {stremail = emailaddress. emailaddress;} // system. diagnostics. debug. writeline ("number:" + strphone + "; Address:" + straddr + "; email:" + stremail); system. diagnostics. debug. writeline ("number:" + strphone + "; email:" + stremail) ;}} void savecontactcompleted (Object sender, savecontactresult e) {Switch (E. taskresult) {Case taskresult. OK: break; Case taskresult. cancel: break; Case taskresult. none: break; default: break;} private void searchphonebookclick (Object sender, routedeventargs e) {contacts getcontacts = new contacts (); getcontacts. searchcompleted + = new eventhandler <contactssearcheventargs> (contactssearchcompleted); getcontacts. searchasync (string. empty, filterkind. none, null);} private void searchphonebookclick2 (Object sender, routedeventargs e) {contacts = new contacts (); contacts. searchcompleted + = new eventhandler <contactssearcheventargs> (contactssearchcompleted); contacts. searchasync (string. empty, filterkind. none, null);} private void addphonebook (Object sender, routedeventargs e) {savecontacttask savecontact = new savecontacttask (); savecontact. completed + = new eventhandler <savecontactresult> (savecontactcompleted); savecontact. firstname = "Leo. zheng "; savecontact. mobilephone = "18665881061"; savecontact. homeaddressstreet = "Shenzhen City, Guangdong Province"; savecontact. personalemail = "doves@126.com"; savecontact. show () ;}# else void objcontacts_searchcompleted (Object sender, contactssearcheventargs e) {var contactsdata = from m in E. results select new mycontacts {displayname = m. displayname, phonenumber = m. phonenumbers. firstordefault ()}; var mycontactslist = from contact in contactsdata group contact by contact. displayname into C orderby C. key select new group <mycontacts> (C. key, c); // This sentence is not compiled using listbox1.itemssource = contactsdata;} public class mycontacts {Public String displayname {Get; set;} public contactphonenumber phonenumber {Get; set ;}} # endif }}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.