0
votes

I have created a new element and app.xaml doesn't want to initialize it. In my App.cs file I'm trying to set my TestPage(I've created TestPage by Add->New Item-> BlankPage) as Main Page but i'm getting this error "Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'smiles.Gridtesst' to 'Xamarin.Forms.Page'" https://i.stack.imgur.com/fK8qg.png

P.S code .xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="smiles.Gridtesst">
  <ContentView.Content>
      <StackLayout>
          <Label Text="Hello Xamarin.Forms!" />
      </StackLayout>
  </ContentView.Content>
</ContentView>

app file

using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace smiles
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new Gridtesst(); // error
        }

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

cs file

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

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace smiles
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Gridtesst : ContentView
    {
        public Gridtesst()
        {
              InitializeComponent();


        }
    }
}
1

1 Answers

0
votes

If you are adding a new page/element then you need to choose Content Page (not content View or another).