gpt4 book ai didi

Xamarin Forms - 隐藏 MasterDetailPage 中的导航栏

转载 作者:行者123 更新时间:2023-12-02 17:33:00 25 4
gpt4 key购买 nike

我需要在 xamarin forms 3.0 中隐藏导航栏

我尝试了这个,但不起作用: Hide Navigation Bar on MasterDetailPage

我想隐藏导航栏来创建自定义栏,我还需要一种打开菜单的方法。谢谢。

App.xaml.cs

public partial class App : Application
{
public App ()
{
InitializeComponent();

MainPage = new MainPage();
}
...

MainPage.xaml.cs

public partial class MainPage : MasterDetailPage
{
public List<MasterPageItem> menuList { get; set; }
public MainPage()
{
InitializeComponent();

menuList = new List<MasterPageItem>();

menuList.Add(new MasterPageItem() { Title = "Home", Icon = "home.png", TargetType = typeof(HomePage) });
menuList.Add(new MasterPageItem() { Title = "Settings", Icon = "setting.png", TargetType = typeof(SettingsPage) });
menuList.Add(new MasterPageItem() { Title = "Help", Icon = "help.png", TargetType = typeof(HelpPage) });

navigationDrawerList.ItemsSource = menuList;

var navPage = new NavigationPage((Page)Activator.CreateInstance(typeof(HomePage)));

//I try this:
NavigationPage.SetHasNavigationBar(navPage, false);
NavigationPage.SetHasBackButton(navPage, false);

Detail = navPage;
}
...

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App3"
x:Class="App3.MainPage">

<MasterDetailPage.Master>
<ContentPage Title="Menu">
<Grid BackgroundColor="Transparent">
<StackLayout Grid.Row="1" Spacing="15">
...
</StackLayout>
</Grid>
</ContentPage>
</MasterDetailPage.Master>

<MasterDetailPage.Detail>
<NavigationPage>

</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

源代码库: https://github.com/uiahhh/stackoverflow/tree/master/HideNavBar

我想删除这个红色圆圈中的导航栏: enter image description here

最佳答案

详细信息页面上,您必须在构造函数中使用 NavigationPage.SetHasNavigationBar(this, false); 删除导航栏InitializeComponent()

public partial class MyPage : NavigationPage
{
public MyPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
}
}

关于Xamarin Forms - 隐藏 MasterDetailPage 中的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51137298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com