简体   繁体   English

使WP8应用与WP7兼容

[英]Make WP8 app compatible with WP7

I recently made an app for Windows Phone 8, and now I want to be able to run it on older devices with WP7.x as well. 我最近为Windows Phone 8开发了一个应用程序,现在我希望也可以在带有WP7.x的旧设备上运行它。 Is this possible without having to make a whole new Visual Studio project targeting WP7 instead of WP8? 是否可以不必针对WP7而不是WP8制作一个全新的Visual Studio项目? I targeted WP8 to make sure I was not held back on available features, but I don't think I ended up using any features that are not available in WP7 anyway, so now I would like to extend with WP7.x compatibility. 我以WP8为目标,以确保不会阻碍我使用可用的功能,但是我不认为我最终还是使用了WP7中不可用的任何功能,因此现在我想扩展WP7.x的兼容性。 Any hints as to how this can be achieved as easily as possible? 关于如何尽可能轻松地实现此目标的任何提示?

Although there's no automated way to "revert" a WP8 project to a WP7 project, it is possible to do it manually, by editing the .csproj file. 尽管没有自动的方法可以将WP8项目“还原”为WP7项目,但可以通过编辑.csproj文件来手动完成。

I don't have my Windows 8 system handy currently so I can't say for sure which items were involved but looking at the project file for a WP7 project, I (seem to) recall adjusting all or some of the the following lines: 我目前没有Windows 8系统,因此无法确定其中涉及哪些项目,但是在查看WP7项目的项目文件时,我(似乎)记得调整以下所有或部分内容:

<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>

<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>

<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>

<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />

<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />

If memory serves, the WP8 project file contains similar lines, and they just need to be replaced with ones above. 如果有内存,则WP8项目文件包含类似的行,只需将它们替换为上面的行。 A comparison between a WP7 project file and WP8 project file should get you on your way. WP7项目文件和WP8项目文件之间的比较应该可以助您一臂之力。 Of course, there might be dependencies that need to be removed or added too. 当然,可能也需要删除或添加依赖项。

Otherwise, there's always the option to start a completely new project :) 否则,总是可以选择启动一个全新的项目:)

You need to create a new WP7 project. 您需要创建一个新的WP7项目。 There may be a way to edit you project and solution files but it would be quicket to just create a new WP7 project and add your existing code to t. 也许可以使用一种方法来编辑项目和解决方案文件,但是只需创建一个新的WP7项目并将现有代码添加到t中,这将是一种快速的方法。

Btw. 顺便说一句。 you should do it the other way around, start with WP7 and upgrade the project to WP8 only if you need the (very few) new features in WP8. 您应该以其他方式进行操作,从WP7开始并将项目升级到WP8,前提是您需要WP8中的(很少)新功能。

You will inevitably have to create another project that targets WP7.x 不可避免地,您将不得不创建另一个针对WP7.x的项目。
But that can be relatively easy, especially if you don't use WP8-only features. 但这可能相对容易,特别是如果您不使用仅WP8的功能。

To improve maintainability, you should consider sharing reusable code files between projects, for example by taking advantage of the "Add as link" functionality of Visual Studio. 为了提高可维护性,您应该考虑在项目之间共享可重用的代码文件,例如,利用Visual Studio的“添加为链接”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM