Reputation: 143
Now I have AppA finished. but I want to make AppB,AppC. and AppB,AppC share most of the code in AppA(including xaml, asset, code,etc.). only a few changes for the AppB,AppC respectively.I mean, the 3 apps can be installed on the same windows phone separately with different icons.
Does anybody know how to build AppB,AppC referring AppA in code? thanks.
Upvotes: 0
Views: 327
Reputation: 2568
Either extract as much as you can in a shared/common project or use "Add as Link" to include files from AppA into AppB and AppC. Note that XAML files don't support conditional compilation so they must be identical for all projects in order to link them. You can potentially extract XAML differences into App.xaml StaticResources (identical keys) in order to make them identical and link them. Sharing XAML is very reasonable when targeting the same platform. You can also link cs files even if they are similar (few changes) by using conditional compilation. Partial classes can also spare you the conditional compilation ceremony in many cases. Finally Resource files are very good candidate for reuse. If you decide to put them on a shared library remember to wrap the generated Resource class in another public one with a public constructor shown here in order to avoid the internal constructor issue.
Upvotes: 1
Reputation: 7122
If you want to share code and assets between multiple assemblies, you can create a class library for Windows Phone and put all the code inside it. When you need to use that library, simply link it in your target applications.
When you want to navigate to a page in your library, use the following syntax:
NavigationService.Navigate(new Uri("/AssemblyName;component/page.xaml", UriKind.Relative));
Upvotes: 0
Reputation: 984
You can put all your code in an external class library. As far as I know though your assets and pages need to exist in each project.
Upvotes: 0