Bug 21217 - Adding Forms Xaml Page does not work
Summary: Adding Forms Xaml Page does not work
Status: RESOLVED ANSWERED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Xamarin.Forms ()
Version: 3.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jose Miguel Torres
URL:
Depends on:
Blocks:
 
Reported: 2014-07-09 19:39 UTC by Victor Vuong
Modified: 2015-10-13 16:14 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Victor Vuong 2014-07-09 19:39:32 UTC
I have created a fresh Xamarin Shared Project. When trying to add a new Forms Xaml Page to the shared project, it creates the XAML output of:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
					   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
					   x:Class="XamarinForms.MyPage">
	<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>

And the .cs output of:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XamarinForms
{
	public partial class MyPage
	{
		public MyPage ()
		{
			InitializeComponent ();
		}
	}
}

This should be deriving from ContentPage and the XAML content also looks incorrect as the <Label> should be in the <ContentPage.Content> container.
Comment 1 Udham Singh 2014-07-10 06:36:41 UTC
I have checked this issue and observed the same behavior mentioned in bug description. Please refer the screencast : http://www.screencast.com/t/bXq4bs1Fo

I have also checked this issue on XS mac and observed that in XAML output we are getting container <ContentPage.Content> and the generated xaml.cs output as below, while in case of VS we are not getting container <ContentPage.Content> in XAML output and also in generated xaml.cs the partial class does not implement class ContentPage.

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace XamarinForms
{
    public partial class MyPage : ContentPage
    {
        public MyPage ()
        {
            InitializeComponent ();
        }
    }
}

To reproduce this issue I have done steps mentioned below : 

1. Open VS 2013
2. Create a new forms application via File -> New -> Project -> Mobile Apps -> Blank App (Xamarin.Forms Portable)
3. Add a new forms xaml page to the shared project via Right click -> Add -> New Item -> Forms Xaml Page

Environment Info : 

Windows 8.1
VS 2013
Xamarin 3.1.215.0
Comment 2 Joaquin Jares 2015-10-13 16:14:27 UTC
The inheritance to ContentPage (or whatever is appropriate) is hidden in a generated file. Same with the label. The behavior is ok as is, except if the project is actually not generating the generated file correctly. Marking as Answered, please reopen if the generated file is incorrect.