I want to create a new Cross-Platform project using C# in Visual Studio 2015 i get just the Android and iOS parts. So how i can add the Windows Phone part in my project ?
3 Answers
You have to install the Windows Phone SDK. And then you can add a Windows Phone Project to your solution File > New > Project
You need to have all of the necessary Windows Phone SDK bits installed for the projects to be added. If you can't create a stand-alone Windows Phone 8/8.1 project in Visual Studio, then Xamarin.Forms won't be able to create the necessary projects.
If you already have these installed, then you can just add the needed projects to the solution, though the Cross-Platform project template should have created them for you.
Adding a Windows Phone App
(Follow the link for a properly formatted view of these instructions)
Firstly, if you used the Xamarin.Forms PCL template, update the profile, then follow the instructions below:
1 right-click on solution > Add > New Project... and add a Blank App (Windows Phone)
2 right-click on the newly created project > Manage NuGet Packages... and add the Xamarin.Forms package.
3 right-click on project > Add > Reference and create a project reference to the shared Xamarin.Forms application project.
4 Edit App.xaml.cs to include the Init() method call, in the OnLaunched method around line 67:
// add this line
Xamarin.Forms.Forms.Init (e); // requires LaunchActivatedEventArgs
// above this existing line
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) {}
5 . Edit MainPage.xaml - change the root element
<forms:WindowsPhonePage
...
xmlns:forms="using:Xamarin.Forms.Platform.WinRT"
...
</forms:WindowsPhonePage>
6 . Edit MainPage.xaml.cs to remove the : PhonePage inheritance specifier for the class name.
public sealed partial class MainPage // REMOVE ": PhonePage"
7 . Still in MainPage.xaml.cs, add the LoadApplication call in the MainPage constructor (around line 28) to start your Xamarin.Forms app:
// below this existing line
this.InitializeComponent();
// add this line
LoadApplication(new YOUR_NAMESPACE.App());
8 . Double-click Package.appxmanifest to set these capabilities that are often required:
Internet (Client & Server)
9 . Finally, add any local resources (eg. image files) from the existing platform projects that are required.
