加入BasePage

目的:將XAML.cs的共同功能,放在basePage,讓代碼更易維護

步驟執行如下

新增BasePage

public partial class BasePage : ContentPage
{
    public BasePage()
    {
      InitializeComponent();
    }
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="HelperAPP.Pages.BasePage">
  <ContentPage.Content>
  </ContentPage.Content>
</ContentPage>

調整.cs繼承的類別

public partial class PhoneQueryResult : BasePage
{ 
}

調整XAML

<?xml version="1.0" encoding="utf-8" ?>
<local:PhoneBasePage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:HelperAPP.Pages;assembly=HelperAPP"
             x:Class="HelperAPP.Pages.PhoneQueryResult">
  <ContentPage.Content>
  </ContentPage.Content>
</local:PhoneBasePage>

results matching ""

    No results matching ""