Search code examples
windows-8windows-phone-8portable-class-library

Using Portable Class Libraries with Windows 8 / Windows Phone 8 MVVM - Page Navigation


I'm developing an app for both Windows 8 and Windows Phone 8. I chose to implement a Portable Class Library and share it between those two platforms. The only problem is that I can't figure out how to handle Page Navigation in the PCL. I've used as an example the folowing tutorial: using portable class library Any help will be highly appreciated. Thanks.


Solution

  • The best approach is to create your own abstraction around navigation.

    I'd create an interface say INavigationService, and then in your non-PCL assemblies for each platform create an implementation of that interface wrapping the appropriate control (Frame for WinRT and PhoneNavigationFrame for Windows Phone 8).

    I'd recommend looking at the source of Caliburn.Micro as it has this similar approach to abstract navigation.

    Here is a sample that shows how to do this: Sharing Code: Adding NavigationService