vitaminJava
vitaminJava

Reputation: 209

MasterDetail Page debugging error: CS0263

I defined a basic master detail page.But whenever I try to start emulator, I am getting this error: "CS0263 Partial declarations of 'MainPage' must not specify different base classes" Its been 1 week and still couldnt solve it. I know it is about inheritance but what should I do ? Any ideas?

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage  xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="MasterDetail.MainPage">

<MasterDetailPage.Master>
    <ContentPage BackgroundColor="White" Title="Master">
        <StackLayout >
            <StackLayout>
                <Frame BackgroundColor="#48b6a6" >
                    <Image Source="heartbeatt.png" HorizontalOptions="Center" 
   VerticalOptions="Center"/>
                </Frame>
            </StackLayout>
        </StackLayout>

    </ContentPage>
</MasterDetailPage.Master>

<MasterDetailPage.Detail>
    <ContentPage>
        <StackLayout>
            <Label Text="Detail"></Label>
        </StackLayout>
    </ContentPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

cs file here

    using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

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

     
    }
}

Upvotes: 0

Views: 197

Answers (1)

Jason
Jason

Reputation: 89082

this is the problem

public partial class MainPage : ContentPage

in the XAML MainPage is a MasterDetailPage, not a ContentPage. Do this instead

public partial class MainPage : MasterDetailPage

this is exactly what the error message is telling you: "must not specify different base classes"

Upvotes: 1

Related Questions