First, create a new project:
Open the development tool file/new project:
, Modify the name defined for the project.
Click OK to go to the following page:
Double-click the Page name font in the lower right corner.PropertiesModify the text content to my browser.
In the leftmost toolbox, drag a button and textbox to the View Interface, and modify the content of the button to go and textbox to http://blog.csdn.net/wangkuifeng0118, and then drag a webbrowsercontrol To The View:
The interface shown in is displayed. The following is added to mainpage. XAML on the right.Code:
<Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <button content = "go" Height = "72" horizontalalignment = "Left" margin = "345,45, 111 "name =" button1 "verticalignment =" TOP "width =" "Click =" button#click "/> <textbox Height =" 72 "horizontalalignment =" Left "margin = ", 356 "name =" textbox1 "text =" http // www.xbox.com "verticalignment =" TOP "width =" "textchanged =" textbox1_textchanged "/> <phone: webbrowser horizontalalignment = "stretch" margin = "," name = "webbrowser1" verticalignment = "stretch" Height = "Auto" width = "Auto"/> </GRID>
Next, add the corresponding button event. Double-click the go button to enter mainpage. XAML. CS:
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; namespace myfirstphone {public partial class mainpage: phoneapplicationpage {// constructor public mainpage () {initializecomponent ();} private void button#click (Object sender, routedeventargs e ){}}}
Write the following code:
Private void button#click (Object sender, routedeventargs e) {// obtain the value string site = textbox1.text in the Textbox Control; // start webbrowser webbrowser1.navigate (New uri (site, urikind. absolute ));}
The Code has been compiled. Let's take a look at running and debugging:
Click the green button to start debugging.
The page appears, and then click go:
Complete. The overall development seems simpler than Android, haha!