How to organize Windows Phone code base to target both 7.x and 8 platforms

最后都变了- 提交于 2019-12-04 06:17:24

The best thing to do is for you to upgrade all the projects to VS2012 in order to be able to support both WP versions (you'll still be able to open the WP7 project in VS2010 despite it being a VS2012 solution, 'cause it's backward compatible).

Regarding the best way to organize the code base, in my opinion you should create a Portable Library that supports both WP7 and WP8 and get all the common code base there (probably mainly the business logic, specially good if you're using a pattern such as MVVM). Not forgetting about the controls issue, you should probably have some different controls for WP8 'cause the screen sizes are not the same and you could get some more info available and use different controls. If you still want to use the same XAML code, have just one file in one of the projects and add that same file "As Link" in the other project you want to re-use it.

Finally, you can, and also probably should, use some conditional code compilation by making use of the #if directive.

Hope that this information helps, and if any code sample is needed, just say so and I'll try to gather something up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!