Ric*_*lho 4 xamarin.ios xamarin.android xamarin xamarin.forms
我需要在 xamarin forms 3.0 中隐藏导航栏。
我尝试这个,但不起作用: Hide Navigation Bar on MasterDetailPage
我想隐藏导航栏来创建自定义栏,我还需要一种打开菜单的方法。谢谢。
应用程序.xaml.cs
public partial class App : Application
{
public App ()
{
InitializeComponent();
MainPage = new MainPage();
}
...
Run Code Online (Sandbox Code Playgroud)
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;
}
...
Run Code Online (Sandbox Code Playgroud)
主页.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>
Run Code Online (Sandbox Code Playgroud)
源代码仓库: https://github.com/uiahhh/stackoverflow/tree/master/HideNavBar
在详细信息NavigationPage.SetHasNavigationBar(this, false);
页面上,您必须在构造函数中删除导航栏InitializeComponent()
public partial class MyPage : NavigationPage
{
public MyPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4151 次 |
最近记录: |