[Windows Phone 8] How to start your browser and specify its URL WebBrowsertask

[Windows Phone 8]How to start the browser and specify its URL WebBrowserTask

Preface

———— ————————————————– —————–

Today I want to teach you how to quickly establish a network link in the APP,

< p>

Like our official website or fan club, you can use this method to allow users to link!

>

Background knowledge

—————————— ————————————————-< /p>

The WebBrowserTask launcher allows the application to launch the browser and navigate to the specified URL.

After constructing the WebBrowserTask, set its Uri attribute, and then < /p>

It can be achieved using the Show method.

Implementation

————————— ————————————————– —-

1. Create a new project

1

2 .Create three Buttons in MainPage.xaml

2

3

 
































< button content="Google" click="OnClick">



< /stackpanel>


3. Then go to MainPage.xaml.cs to write the Click event p>

4

private void OnClick(object sender, RoutedEventArgs e)

{
Button btn = e.OriginalSource as Button;
if (btn != null)
{
string strContent = btn.Content.ToString();
string MyUri = string.Empty;
//Determine which button to click
switch (strContent)
{
case "Michael's Study Room":
MyUri = "http://www.dotblogs.com.tw/michael80321";
break;
case "Google":
MyUri = "https://www.google.com.tw/webhp?hl=zh-TW";
break;
case "Yahoo":
MyUri = "http://tw.yahoo.com/";
break;
default:
break;
}
//Construct WebBrowserTask launcher
Microsoft.Phone.Tasks.WebBrowserTask myWeb = new Microsoft.Phone.Tasks.WebBrowserTask();
//Uri to browse
myWeb.Uri = new Uri(MyUri);
//Display the launcher interface
myWeb.Show();
}
}

4. Let’s take a look at it

5

6

< p> 7

8

9

10

Conclusion

————- ————————————————– —————————————–

Is it right? It’s very simple! Do it yourself ^_^

I hope to help you ^_^

If there are errors in the above, please feel free to advise! Thank you all

< p> Reference data

————————————— ————————————————– —————

How to use the web browser task for Windows Phone

WebBrowserTask Class-MSDN

Original: Large column [Windows Phone 8] How to start the browser and specify its URL WebBrowserTask

Leave a Comment

Your email address will not be published.