title: Xamarin.Forms - InitializeComponent doesn't exist when creating a new page
body: <p>I'm using Visual Studio to try out Xamarin.Forms. I'm trying to follow the guide:
  <a href="http://developer.xamarin.com/guides/cross-platform/xamarin-forms/xaml-for-xamarin-forms/getting_started_with_xaml/" rel="noreferrer">http://developer.xamarin.com/guides/cross-platform/xamarin-forms/xaml-for-xamarin-forms/getting_started_with_xaml/</a></p>
  
  <p>In short, I create a Xamarin.Forms solution using a PCL and then try to add a <code>Forms XAML Page</code> to the PCL-project.</p>
  
  <p>The code-behind that gets created looks like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    public partial class Page1 : ContentPage
      {
          public Page1()
          {
              InitializeComponent(); 
          }
      }
  </code></pre>
  
  <p>The problem here is that <code>InitializeComponent();</code> is red.
  When I try to build I get informed that <code>The name 'InitializeComponent' does not exist in the current context</code>  </p>
  
  <p>I've been looking around for solutions and even though others have had the same trouble, their solutions wont work for me. Here is one suggestion i tried to use:
  <a href="http://blog.falafel.com/xamarin-error-initializecomponent-does-not-exist-in-the-current-context/" rel="noreferrer">http://blog.falafel.com/xamarin-error-initializecomponent-does-not-exist-in-the-current-context/</a></p>
  
  <p>Please let me know if you have a solution for this problem. Thanks!</p>
  
  <p>Update:</p>
  
  <p>My PCL (which is where I also want to add my XAML-page) contains:</p>
  
  <p>App.cs:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    public class App : Application
      {
          public App()
          {
              // The root page of your application
              MainPage = new ContentPage
              {
                  Content = new StackLayout
                  {
                      VerticalOptions = LayoutOptions.Center,
                      Children = {
                          new Label {
                              XAlign = TextAlignment.Center,
                              Text = "Welcome to Xamarin Forms!"
                          }
                      }
                  }
              };
          }
  
          protected override void OnStart()
          {
              // Handle when your app starts
          }
  
          protected override void OnSleep()
          {
              // Handle when your app sleeps
          }
  
          protected override void OnResume()
          {
              // Handle when your app resumes
          }
      }
  </code></pre>
  
  <p>And my XAML-page:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               x:Class="XamaTest.MyXamlPage"&gt;
      &lt;Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" /&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>Code-behind:</p>
  
   <pre class="lang-cs prettyprint-override"><code>    public partial class MyXamlPage : ContentPage
      {
          public MyXamlPage()
          {
              InitializeComponent();
          }
      }
  </code></pre>