Windows Phone 8 - Using native pages
This tutorial explains how to create and integrate native and web "pages" in a Windows Phone 8 application by using the
This tutorial covers the following topics:
- Creating a native page
- Returning control to the web view
- Sample application
- Implement the
WL.NativePage.show()to open the native page.
nativePageClassName: The name of a native WP8 class to start.
backFromNativePage: A callback function to call when the native page closes.
params: An optional custom parameters object to pass to the native code.
- To handle the callback function:
backFromNativePage(data)parameter can pass data back to the web part of an application after the native closes.
Creating a native page
For Windows Phone 8, implement the native page as a Windows Phone User Control, or extend an existing one.
In the new User Control, add
using Cordova.Extension.Commands; to the
.cs file, and use the same package and class name as in the
To retrieve custom data parameters that are passed from the web view, use the
In the example below, the data is sent as a JSON string. For this purpose, the external
JSON.NET library is used to convert the incoming JSON string to a native dictionary. For more information, see the JSON.NET page.
Returning control to the web view
When the native page needs to switch back to the web view, it calls the
Data can be passed back to the web view as parameters to the call.
Click to download the Studio project.