This sample shows how to use the WebBrowser control in your Windows Phone app. The sample takes a URL from the user and navigates to the specified page. It also automatically adjusts to portrait and landscape modes.

You need to install the Windows Phone SDK to run this sample. To get started, go to the Windows Phone Dev Center.

For more info about building this app, see How to create your first app for Windows Phone in the MSDN Library.

Building and debugging the app

The following steps show you how to build and debug this sample.

Important Note:

Before you test the app, make sure that your computer has internet access to be able to test the Web browser control.

To build and debug the app

  1. Build the solution by selecting the BUILD | Build Solution menu command. The project should build without any errors in the Error List window. You can open the Error List window, if it is not already open, by selecting the VIEW | Error List menu command. If there are errors, review the steps above, correct any errors, and then build the solution again.

  2. On the standard toolbar, make sure the deployment target for the app is set to one of the values for the Windows Phone Emulator, for example, Emulator WVGA.

  3. Run the app by pressing F5 or by selecting the DEBUG | Start Debugging menu command. This opens the emulator window and launches the app.

  4. To test your running app, click the Go button and verify that the browser goes to the specified website.

  5. To test the app in landscape mode, press one of the rotation controls on the emulator. These are the buttons that show a horizontal and a vertical rectangle.

    When the emulator rotates to landscape mode, the controls resize themselves to fit the landscape screen format.

  6. To stop debugging, you can select the DEBUG | Stop Debugging menu command.

Note:

This sample is packaged as a Windows Phone 7.5 project. It can be converted to a Windows Phone 8 project, by changing the target Windows Phone OS version of the project. To create a Windows Phone 8 project, you must be running the Windows Phone SDK 8.0 on Visual Studio 2012. You can download the latest version of the SDK from http://dev.windowsphone.com/downloadsdk.

To convert the sample to a Windows Phone 8 project:

  1. Double-click the .sln file to open the solution in Visual Studio.

  2. Right-click the project in the Solution Explorer and select Properties. This opens the Project Properties window.

  3. In the Application tab of the Project Properties window, select Windows Phone OS 8.0 from the Target Windows Phone OS Version dropdown. A dialog will appear asking if you want to upgrade this project to Windows Phone OS 8.0.

  4. Select Yes to upgrade the project.