Что мне нужно сделать, чтобы страница PartsBuyDetail унаследовала NewBasePage?
Вот моя разметка XAML NewBasePage:
Код: Выделить всё
Код: Выделить всё
using Microsoft.Maui.Controls;
namespace HomeUpKeepPro.Views
{
public partial class NewBasePage : ContentPage
{
public NewBasePage()
{
InitializeComponent();
}
protected void OnAddClicked(object sender, EventArgs e)
{
// Handle the Add button click event
}
protected void OnSaveClicked(object sender, EventArgs e)
{
// Handle the Save button click event
}
protected void OnDeleteClicked(object sender, EventArgs e)
{
// Handle the Delete button click event
}
}
}
Код: Выделить всё
protected Label TitleLabel { get; private set; }
protected Label TaskTitleLabel { get; private set; }
protected CollectionView ItemsCollectionView { get; private set; }
protected Label DetailLabel { get; private set; }
Вот моя разметка PartsBuyDetail.xaml (для страницы, которая должна наследовать от NewBasePage):
Код: Выделить всё
Код: Выделить всё
using Microsoft.Maui.Controls;
using System.Collections.ObjectModel;
using HomeUpKeepPro.Models;
namespace HomeUpKeepPro.Views
{
public partial class PartsBuyDetail : NewBasePage
{
public PartsBuyDetail()
{
InitializeComponent();
// Populate data in code-behind
TitleLabel.Text = "Parts Buy Detail";
TaskTitleLabel.Text = "Task: Buy Parts";
var parts = new ObservableCollection
{
new PartsBuy { SourceName = "Home Depot", SourceURL = "www.homedepot.com" },
new PartsBuy { SourceName = "Lowes", SourceURL = "www.lowes.com" }
};
ItemsCollectionView.ItemsSource = parts;
DetailLabel.Text = "Details about buying parts.";
}
}
}
CS0122 «NewBasePage.TitleLabel» недоступен из-за уровня защиты PartsBuyDetail. .Xaml.cs 13
CS0122 «NewBasePage.TaskTitleLabel» недоступен из-за уровня защиты. PartsBuyDetail.Xaml.cs 14
CS0122 «.ItemsCollectionView» недоступен из-за уровня защиты PartsBuyDetail.Xaml.cs 20
CS0122 «NewBasePage.DetailLabel» недоступен из-за его уровень защиты PartsBuyDetail.Xaml.cs 21
Подробнее здесь: https://stackoverflow.com/questions/792 ... n-net-maui
Мобильная версия