简体   繁体   中英

How to share code and resources between projects

I have two projects named Project 1 and Project 2. I am porting my application from iOS to WP8 and I have ported my iOS_Project 1 to WP8_Project 1. In iOS I have the flexibility to add the files as references and thereby I can achieve code reuse. I would like to perform the same process in WP8, but I couldn't find proper help and here's the question. (Here I want to refer all the classes, images and xaml files like MainPage.xaml)

I know pretty sure about one thing that wpf/forms/.NET projects differ with WP8 structure. Please do provide some help.

Thanks.

You can use references in Visual Studio 2012 - there is no problem. However, PCL ( Portable Class Library ) is a better solution. Here is example how to add files as link in Visual Studio 2012.

When you have add your item to one project, select the option to Add Existing Item to the other project. Navigate to the item you want to add and then you should find a drop-down arrow on the appropriate button to allow you to add the item as a link. That means that there will only ever be one copy of that item but it will be used in both projects.

That said, if possible, I would suggest that you break the common functionality out into a library project that you then reference in both the other projects. If you create a portable library then you could use it in a Windows 8 app as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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