<! -- Titlepanel contains applicationsProgramName and page title -->
<Stackpanel X: Name = "titlepanel" grid. Row = "0" margin = ",">
<Textblock X: Name = "applicationtitle" text = "My applications" style = "{staticresource phonetextnormalstyle}"/>
<Textblock X: Name = "pagetitle" text = "send SMS" margin = "9,-7,0, 0" style = "{staticresource phonetexttitle1style}"/>
</Stackpanel>
<! -- Contentpanel-place other content here -->
<Grid X: Name = "contentpanel" grid. Row = "1" margin = "12,0, 12,0">
<Textblock Height = "40" horizontalalignment = "Left" margin = "25, 16," name = "textblock1" text = "Recipient: "verticalalignment =" TOP "fontsize =" 30 "width =" 144 "/>
<Textbox Height = "72" horizontalalignment = "Left" margin = "444," name = "txtphonenumber" text = "" verticalalignment = "TOP" width = "">
<Textbox. inputscope>
<Inputscope>
<Inputscopename namevalue = "Number"/>
</Inputscope>
</Textbox. inputscope>
</Textbox>
<Textblock textwrapping = "Wrap" fontsize = "30" Height = "177" horizontalalignment = "Left" margin = "6,270, 0, 0 "name =" textblock2 "text =" text message content "verticalalignment =" TOP "width =" 46 "/>
<Textbox Height = "406" horizontalalignment = "Left" margin = "48,140, 382 "name =" txtmessage "text =" "verticalalignment =" TOP "width =" "textwrapping =" Wrap "/>
<Button content = "send" Height = "79" horizontalalignment = "Left" margin = "-12,538, 480 "name =" btnsend "verticalignment =" TOP "width =" "Click =" btnsend_click "/>
<Button content = "Select phone number" Height = "69" horizontalalignment = "Left" margin = "210,0, 220 "name =" btnchoose "verticalignment =" TOP "width =" "Click =" btnchoose_click "/>
</GRID>
</GRID>
BackgroundCode:
Phonenumberchoosertask mychooser = new phonenumberchoosertask ();
Smscomposetask SMS = NULL;
// constructor
Public mainpage ()
{< br> initializecomponent ();
// instantiate
SMS = new smscomposetask ();
// register a callback event
mychooser. completed + = (sender, e) =>
{< br> If (E. taskresult = taskresult. OK)
{< br> dispatcher. begininvoke () => {this.txt phonenumber. TEXT = E. phonenumber ;});
}< BR >};
}
// select the contact
private void btnchoose_click (Object sender, routedeventargs e)
{< br> If (mychooser = NULL)
{< br> mychooser = new phonenumberchoosertask ();
}< br> mychooser. show ();
}
// send
private void btnsend_click (Object sender, routedeventargs e)
{< br> If (txtphonenumber. TEXT = "" | txtmessage. TEXT = "")
{< br> MessageBox. show ("the recipient number and text message content cannot be blank. ");
return;
}< br> If (SMS = NULL)
{< br> SMS = new smscomposetask ();
}< br> // value assignment
SMS. to = txtphonenumber. text;
SMS. body = txtmessage. text;
Try
{
SMS. Show ();
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
}