0

When I create a blank Xamarin.Forms application, there isn't a WinPhone application loaded, why ?

Note:
I'm trying on Windows.

Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87

3 Answers3

0

If you create it from Xamarin Studio, you'll get only Android and iOS projects. You need Visual Studio to have WinPhone, Windows, and UWP projects created. Furthermore, you need to have the corresponding SDKs in order to load and build the projects.

As it is stated in the official documentation,

Developing Xamarin.Forms applications for Windows platforms requires Visual Studio. The requirements page contains more information about the pre-requisites.

Luis Beltran
  • 1,704
  • 12
  • 13
0

You have to manually add it from within Visual Studio to your multi-platform mobile solution and then you can add the Xamarin.Forms nuget to it.

Complete steps (follow the link):

Adding a Windows Phone App

  • Right-click on solution > Add > New Project... and add a Blank App (Windows Phone)

enter image description here

Right-click on the newly created project > Manage NuGet Packages... and add the Xamarin.Forms package.

Right-click on project > Add > Reference and create a project reference to the shared Xamarin.Forms application project.

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) {}

Edit MainPage.xaml - change the root element

<forms:WindowsPhonePage
...
   xmlns:forms="using:Xamarin.Forms.Platform.WinRT"
...
</forms:WindowsPhonePage>

Edit MainPage.xaml.cs to remove the : PhonePage inheritance specifier for the class name.

public sealed partial class MainPage  // REMOVE ": PhonePage"

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());

Double-click Package.appxmanifest to set these capabilities that are often required:

Internet (Client & Server)

  • Finally, add any local resources (eg. image files) from the existing platform projects that are required.
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
0

I have now WinPhone application in blank .Forms application, and also the Universal Windows projects.

What I did for this :

I did all the things in Sanjisan's answer in this page

Uninstall Xamarin completely, and reinstall it. That happened to me as well. I would uninstall Visual studio too. Install that first, then install Xamarin.

Edit: I know this sucks to do, but it was what the Xamarin team had me do to resolve it. As far as I know this is the official fix as of last week.

Community
  • 1
  • 1
Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87