Reputation: 11
I want to remove the navigation bar from the top, but I haven't been able to, this is my code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage NavigationPage.HasNavigationBar="false"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Encuestadefensoria1.MainPage"
xmlns:local="clr-namespace:Encuestadefensoria1"
>
<AbsoluteLayout>
<AbsoluteLayout>`
y este es el CS
sing System.Linq;
using Microsoft.Maui.Controls;
using System.Globalization;
namespace x;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
AppShell.SetNavBarIsVisible(this, false);
}
I tried everything I read about this, but nothing worked for me, help
Upvotes: 0
Views: 3507
Reputation: 43
On each page where you don't want to see the navigation bar
, add the following code
NavigationPage.HasNavigationBar="False"
to your content page
right after,
xmlns:local="clr-namespace:Encuestadefensoria1"
Upvotes: 3
Reputation: 9438
As I understand it, you want to have the navigation pages displayed without the navigation bar.
When I have needed to do this, it works for me to set the Shell.NavBarIsVisible
property up front in the AppShell.xaml file. I see you have tried to set this in the MainPage
constructor. See if it works if you do this instead.
<Shell
x:Class="Encuestadefensoria1.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Encuestadefensoria1"
Shell.FlyoutBehavior="Flyout"
Shell.NavBarIsVisible="False">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
</Shell>
I tested this just now with the default MAUI project (without modifying MainPage or anything else). It seems to do the trick in the build for Android and Windows Machine.
Upvotes: 4