xaml - MasterDetail页面调试错误:CS0263
问题描述
我定义了一个基本的主详细信息页面。但是每当我尝试启动模拟器时,我都会收到此错误:“CS0263 'MainPage' 的部分声明不能指定不同的基类”它已经 1 周了,仍然无法解决它。我知道这是关于继承,但我该怎么办?有任何想法吗?
<?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文件在这里
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();
}
}
}
解决方案
这就是问题
public partial class MainPage : ContentPage
在 XAML MainPage 中是一个MasterDetailPage
,而不是一个ContentPage
. 改为这样做
public partial class MainPage : MasterDetailPage
这正是错误消息告诉您的内容:“不得指定不同的基类”
推荐阅读
- django - AWS Django 日志中的多个错误apps.populate(settings.INSTALLED_APPS)
- apache-spark - Spark-Scala Try Select 语句
- excel - 如何根据 2 个单元格的值更改单元格的颜色
- python - 如何在不挂起/冻结 Python 的情况下为 pygame 混音器正确打开和关闭音乐文件?
- python - Python:更改小部件子配置会复制 tkinter 中的小部件
- powerbi - 电源查询添加可扩展年份列
- php - 双向关系ManyToMany symfony
- java - 将元素从一个 int 列表删除到另一个
- java - 处理推送菜单项。安卓
- c# - C# 7.2 对运算符使用“in parameter”