我有这个非常简单的基页,它继承了ContentPage类:
using Xamarin.Forms;
namespace C4SL.LEAP.Mobile.Code.Views
{
public abstract class LEAPPage : ContentPage
{
public String Breadcrumb { get; set; }
public LEAPPage()
{
this.Breadcrumb = String.Empty;
}
}
}
现在当我从LEAPPage而不是ContentPage继承我的视图类时,我在覆盖OnAppearing()方法时遇到了一些奇怪的麻烦,说明没有找到合适的方法来覆盖' ..我在这里一定很容易遗漏的东西..有人可以帮助我吗?
我的视图类如下所示:
using Plugin.Connectivity;
using Plugin.Connectivity.Abstractions;
using C4SL.LEAP.Mobile.Code.Views;
namespace C4SL.LEAP.Mobile.Fundamentals
{
public partial class Main : LEAPPage
{
public Main()
{
InitializeComponent();
CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged;
}
private void Current_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
{
}
protected override void OnAppearing()
{
base.OnAppearing();
if (CrossConnectivity.Current.IsConnected)
{
}
}
}
}
答案 0 :(得分:1)
我自己找到了解决方案:
https://forums.xamarin.com/discussion/27265/contentpage-inherit-from-custom-basepage
问题是我的viewclass是偏的,我不得不在XAML文件中添加引用。