WP7 development: creating the first Silverlight Application

Source: Internet
Author: User

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!

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.