Windows Phone 8 - Using native pages
OverviewIn this tutorial, integration of native and web "pages" in a Windows Phone 8 application will be explained by using the
WL.NativePage.show()needs to be implemented in order to open the native page:
nativePageClassName: The name of a native Windows Phone 8 UIViewController instance to start.
backFromNativePage: A callback function to call when the native page closes.
params: optional custom parameters object to pass to the native code.
To handle the callback function:
backFromNativePage(data): After the native closes, it can pass data back to the web part of an application.
Creating a native pageFor WP8, the native page must be implemented as a Windows Phone User Control, or extend an existing one.
Step 1In the new User Control, add
using Cordova.Extension.Commands;to the .cs file, and use the same package and class name as in the
Step 2To retrieve custom data parameters that are passed from the web view, the
WLNativePage.Datamethod should be used. In the below example, 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 http://json.codeplex.com/
Returning control to the web viewWhen the native page needs to switch back to the web view, it calls the
WLNativePage.backFromNativemethod. Data can be passed back to the web view as parameters to the call:
Sample applicationClick to download the Studio project. ▲
Last modified on November 09, 2016