Xamarin 制作选项卡式应用程序时,是否创建新的导航页或内容页?
我想创建一个带有选项卡的应用程序。我不需要导航页面的功能,它允许我返回到最后一个屏幕。我只希望选项卡栏允许我从五个页面中选择一个 以下是我目前掌握的代码:Xamarin 制作选项卡式应用程序时,是否创建新的导航页或内容页?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我想创建一个带有选项卡的应用程序。我不需要导航页面的功能,它允许我返回到最后一个屏幕。我只希望选项卡栏允许我从五个页面中选择一个 以下是我目前掌握的代码: public partial class MainPage : TabbedPage { public MainPage() { InitializeComponent(); 我的问题是我应该使用以下哪项。请注意,主页继承自ContentPage // this is the one the
public partial class MainPage : TabbedPage
{
public MainPage()
{
InitializeComponent();
我的问题是我应该使用以下哪项。请注意,主页继承自ContentPage
// this is the one the app uses now. Do I really need to NavigationPage and then inside that another page HomePage?
var homePage = new NavigationPage(new HomePage())
{
Title = "Home",
Icon = "ionicons_2_0_1_home_outline_25.png"
};
// I thought this would be better but ContentPage constructor cannot take an argument
var homePage = new ContentPage(new HomePage())
{
Title = "Home",
Icon = "ionicons_2_0_1_home_outline_25.png"
};
// this is my latest thought but would like to hear from others
var homePage = new HomePage()
{
Title = "Home",
Icon = "ionicons_2_0_1_home_outline_25.png"
};
Children.Add(homePage);
建议在选项卡页面
中填充
NavigationPage
和ContentPage
仅限实例。这将有助于确保
跨所有平台的一致用户体验
上面的引文来自官方
NavigationPage
包装ContentPage
HomePage
是从ContentPage
继承的,则您只需创建它的实例,然后用下一种方法将其添加到子项:附言:已经很好地涵盖了导航主题。请熟悉一下 建议在
选项卡页面
中填充
NavigationPage
和ContentPage
仅限实例。这将有助于确保
跨所有平台的一致用户体验
上面的引文来自官方
NavigationPage
包装ContentPage
HomePage
是从ContentPage
继承的,则您只需创建它的实例,然后用下一种方法将其添加到子项:附言:已经很好地涵盖了导航主题。请熟悉它。查看文档时,我仍然感到困惑。为什么他们要指定一个包含SchedulePageCS的导航页面。为什么不让SchedulePageCS本身成为一个导航页面呢?var navigationPage=newnavigationpage(newschedulepagecs());ContentPage和NavigationPage之间存在差异。文档展示了这两种方法。查看文档我仍然感到困惑。为什么他们要指定一个包含SchedulePageCS的导航页面。为什么不让SchedulePageCS本身成为一个导航页面呢?var navigationPage=newnavigationpage(newschedulepagecs());ContentPage和NavigationPage之间存在差异。这些文件演示了这两种方法。
var homePage = new HomePage
{
Title = "Home",
Icon = "ionicons_2_0_1_home_outline_25.png"
};
Children.Add(homePage);