Windows Phone 8.1 and Windows Runtime Apps How to #16 – Displaying External Web Page with in a Windows Phone 8.1 App

In Windows Phone 8 and earlier version , the developers could use the WebBrowser control or the WebBrowserTask to display external webpages within the app .

If you want to display an external webpage within your Windows Phone 8.1 Windows runtime app , you can use the WebView which provides the page a control which can host some HTML content.

How to display external web page with in a Windows Phone 8.1 App ?

1. Simply add the WebView control to the page from the toolbox or by adding the below tag . Provide a name to the WebView control . In this example , the control name is provided as “MobileOSGeekView”.

<Grid>
  <WebView x:Name="MobileOSGeekView">           
  </WebView>
</Grid>

2. Use the Navigate method of the WebView object by providing the necessary Uri which you need to display in a WebView.

private void LaunchMobileOSGeekWebsite()
{
           
   Uri NavigateUrl = new Uri(@"http://www.developerpublish.com");
   // Navigate to the MobileOSGeek website within the webview
   MobileOSGeekView.Navigate(NavigateUrl);

}

3. When you call the above method , you will see the external webpage being loaded in to the WebView control of the page.

image

Leave a Reply