Windows Phone development (25): starter and selector-webbrowsertask to: http://blog.csdn.net/tcjiaan/article/details/7404770

Source: Internet
Author: User

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?

  1. <Phone: phoneapplicationpage
  2. X: class = "webtask. mainpage"
  3. Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
  5. Xmlns: Phone = "CLR-namespace: Microsoft. Phone. controls; Assembly = Microsoft. Phone"
  6. Xmlns: shell = "CLR-namespace: Microsoft. Phone. Shell; Assembly = Microsoft. Phone"
  7. Xmlns: D = "http://schemas.microsoft.com/expression/blend/2008"
  8. Xmlns: MC = "http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. MC: ignorable = "D" D: designwidth = "480" D: designheight = "768"
  10. Fontfamily = "{staticresource phonefontfamilynormal }"
  11. Fontsize = "{staticresource phonefontsizenormal }"
  12. Foreground = "{staticresource phoneforegroundbrush }"
  13. Supportedorientations = "portrait" orientation = "portrait"
  14. Shell: systemtray. isvisible = "true">
  15. <! -- Layoutroot is the root mesh that contains all page content -->
  16. <Grid X: Name = "layoutroot" background = "Transparent">
  17. <Grid. rowdefinitions>
  18. <Rowdefinition Height = "Auto"/>
  19. <Rowdefinition Height = "*"/>
  20. </Grid. rowdefinitions>
  21. <! -- Titlepanel contains the application name and page title -->
  22. <Stackpanel X: Name = "titlepanel" grid. Row = "0" margin = ",">
  23. <Textblock X: Name = "applicationtitle" text = "My applications" style = "{staticresource phonetextnormalstyle}"/>
  24. <Textblock X: Name = "pagetitle" text = "Start Web Browser" margin = "9,-, 0" fontsize = "50"/>
  25. </Stackpanel>
  26. <! -- Contentpanel-place other content here -->
  27. <Grid X: Name = "contentpanel" grid. Row = "1" margin = "12,0, 12,0">
  28. <Textblock Height = "40" horizontalalignment = "Left" margin = "38,57," name = "textblock1" text = "Enter the URL: "verticalalignment =" TOP "width =" 286 "fontsize =" 28 "/>
  29. <Textbox Height = "72" horizontalalignment = "Left" margin = "12,122, 394" name = "txturl" verticalalignment = "TOP" width = ""/>
  30. <Button content = "set and start" Height = "79" horizontalalignment = "Left" margin = "12,222, 394 "name =" button1 "verticalignment =" TOP "width =" "Click =" button#click "/>
  31. <Button content = "set and start" Height = "79" horizontalalignment = "Left" margin = "9,323, 394 "name =" button2 "verticalignment =" TOP "width =" "Click =" button2_click "/>
  32. </GRID>
  33. </GRID>
  34. </Phone: phoneapplicationpage>

 

[CSHARP]View plaincopyprint?

  1. Using system;
  2. Using system. Collections. Generic;
  3. Using system. LINQ;
  4. Using system. net;
  5. Using system. windows;
  6. Using system. Windows. controls;
  7. Using system. Windows. documents;
  8. Using system. Windows. input;
  9. Using system. Windows. Media;
  10. Using system. Windows. Media. animation;
  11. Using system. Windows. shapes;
  12. Using Microsoft. Phone. controls;
  13. Using Microsoft. Phone. tasks;
  14. Namespace webtask
  15. {
  16. Public partial class mainpage: phoneapplicationpage
  17. {
  18. // Constructor
  19. Public mainpage ()
  20. {
  21. Initializecomponent ();
  22. }
  23. Private void button#click (Object sender, routedeventargs E)
  24. {
  25. // Set through URI object
  26. Webbrowsertask Wt = new webbrowsertask ();
  27. Wt. uri = new uri (txturl. Text, urikind. Absolute );
  28. Wt. Show ();
  29. }
  30. Private void button2_click (Object sender, routedeventargs E)
  31. {
  32. // Set by string
  33. Webbrowsertask Wt = new webbrowsertask ();
  34. Wt. url = txturl. text;
  35. Wt. Show ();
  36. }
  37. }
  38. }

 

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.