user3741975
user3741975

Reputation: 61

Unknown type 'ContentPage' in XML namespace 'http://xamarin.com/schemas/2014/forms'

I'm writing an application in MVVM. My MainPage.xaml looks like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:view="using:FIARView"
                 xmlns:controls="using:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"
                 x:Class="clr-namespace:FIARView.MainPage">
...

And everything that I use in this xaml file has an error: for example:

Unknown type 'ContentPage' in XML namespace 'http://xamarin.com/schemas/2014/forms'
Unknown type 'Button' in XML namespace 'http://xamarin.com/schemas/2014/forms'

etc. I tried searching for an answer but didn't find it. How can I solve this problem?

Upvotes: 1

Views: 2869

Answers (3)

Poppyto
Poppyto

Reputation: 614

You probably created a Page with copy paste in the explorer and including in the project, so you missed these xaml properties :

  • Build action to "Embedded resource"
  • Custom Tool to "MSBuild:UpdateDesignTimeXaml":

Build Action and Custom Tool

Upvotes: 6

therealjohn
therealjohn

Reputation: 2398

Make sure that you are editing XAML in the PCL/Shared project and not the WinRT platform project. Here is a tutorial to help you get started too.

Windows projects also use XAML so that can be confusing. For Xamarin.Forms you will be creating the UI in the shared (PCL or Shared Assets) projects and it's types are specific to Forms.

Upvotes: 0

David
David

Reputation: 1196

I dont think the issue your having is with the Xaml. Its more likely its your code behind that has the problem.

FIARView.MainPage Should look Like

using Xamarin.Forms;

namespace FAIRVIEW
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
    }
}

Another possibility is your code behind Base Class.

When you say your using MVVM Im guessing it means your using something Like MVVMCross etc. Some of these want you to change your base class in your Code behind to something other then ContentPage. When you do this you then need to change the Tag in your Xaml as well to the new Base Class.

Upvotes: 0

Related Questions