As you can see from the name, this guy just opens the browser and browses the specified page.
It has two identical attributes: The URI attribute is of the system. Uri type, which is a newly written attribute;
The URL is of the string type, but if this attribute is used, a warning "expired" will be issued, so we recommend that you use the former.
In the following example, after clicking the button, the Web browser is opened and the address entered in the text box is located. However, the two attributes mentioned above are used respectively. After the program runs, you will find that the effect is the same.
[HTML]View plaincopyprint?
- <Phone: phoneapplicationpage
- X: class = "webtask. mainpage"
- Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
- Xmlns: Phone = "CLR-namespace: Microsoft. Phone. controls; Assembly = Microsoft. Phone"
- Xmlns: shell = "CLR-namespace: Microsoft. Phone. Shell; Assembly = Microsoft. Phone"
- Xmlns: D = "http://schemas.microsoft.com/expression/blend/2008"
- Xmlns: MC = "http://schemas.openxmlformats.org/markup-compatibility/2006"
- MC: ignorable = "D" D: designwidth = "480" D: designheight = "768"
- Fontfamily = "{staticresource phonefontfamilynormal }"
- Fontsize = "{staticresource phonefontsizenormal }"
- Foreground = "{staticresource phoneforegroundbrush }"
- Supportedorientations = "portrait" orientation = "portrait"
- Shell: systemtray. isvisible = "true">
- <! -- Layoutroot is the root mesh that contains all page content -->
- <Grid X: Name = "layoutroot" background = "Transparent">
- <Grid. rowdefinitions>
- <Rowdefinition Height = "Auto"/>
- <Rowdefinition Height = "*"/>
- </Grid. rowdefinitions>
- <! -- Titlepanel contains the application name 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 = "Start Web Browser" margin = "9,-, 0" fontsize = "50"/>
- </Stackpanel>
- <! -- Contentpanel-place other content here -->
- <Grid X: Name = "contentpanel" grid. Row = "1" margin = "12,0, 12,0">
- <Textblock Height = "40" horizontalalignment = "Left" margin = "38,57," name = "textblock1" text = "Enter the URL: "verticalalignment =" TOP "width =" 286 "fontsize =" 28 "/>
- <Textbox Height = "72" horizontalalignment = "Left" margin = "12,122, 394" name = "txturl" verticalalignment = "TOP" width = ""/>
- <Button content = "set and start" Height = "79" horizontalalignment = "Left" margin = "12,222, 394 "name =" button1 "verticalignment =" TOP "width =" "Click =" button#click "/>
- <Button content = "set and start" Height = "79" horizontalalignment = "Left" margin = "9,323, 394 "name =" button2 "verticalignment =" TOP "width =" "Click =" button2_click "/>
- </GRID>
- </GRID>
- </Phone: phoneapplicationpage>
[CSHARP]View plaincopyprint?
- 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. tasks;
- Namespace webtask
- {
- Public partial class mainpage: phoneapplicationpage
- {
- // Constructor
- Public mainpage ()
- {
- Initializecomponent ();
- }
- Private void button#click (Object sender, routedeventargs E)
- {
- // Set through URI object
- Webbrowsertask Wt = new webbrowsertask ();
- Wt. uri = new uri (txturl. Text, urikind. Absolute );
- Wt. Show ();
- }
- Private void button2_click (Object sender, routedeventargs E)
- {
- // Set by string
- Webbrowsertask Wt = new webbrowsertask ();
- Wt. url = txturl. text;
- Wt. Show ();
- }
- }
- }