简体   繁体   English

Windows Phone 7和Windows Phone 8 / Windows 8(Windows应用商店)之间的代码共享

[英]Code Sharing between Windows Phone 7 and Windows Phone 8 / Windows 8 (Windows Store)

I have a Silverlight 4 class library written in C# that I use as common code for my Windows Phone 7 projects. 我有一个用C#编写的Silverlight 4类库,可用作Windows Phone 7项目的通用代码。

What I want is to use this (basic, platform-independent) code in my Windows Phone 8 and Windows 8 Apps too. 我想在Windows Phone 8和Windows 8 Apps中也使用此(基本的,与平台无关的)代码。

Is there any way? 有什么办法吗?

It's not strong-necessary that the common code has to be stored in a Silverlight 4 (v5 seems not supported by WP7) project. 通用代码不必存储在Silverlight 4(WP7似乎不支持v5)项目中不是很必要。

Set the common code up as a "portable class library" project, targeting the platforms you want (Silverlight and Windows Store in this case). 将通用代码设置为“便携式类库”项目,以所需平台为目标(在这种情况下为Silverlight和Windows Store)。 This gives you access to the intersection of those frameworks. 这使您可以访问这些框架的交集。 This can then be referenced and used by the framework-specific shell projects. 然后可以由特定于框架的shell项目引用和使用它。

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

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