Set Top Bar Burger Menu

Asked

Viewed 287 times

2

I made an app with a Login screen to a Mainview that is a Masterdetail and a Detail. It is working correctly but the top screen is larger than normal, as per image; as I set it to be the correct size?

Imagem do APP onde tem a Barra azul esta maior que o normal.
Follow Mainview, Master and Detail XAML code.

Mainview.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:MVVMApp"
             x:Class="MVVMApp.Views.MainView">
</MasterDetailPage>

Master xaml.

 <?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="MVVMApp.Views.Master"
             BackgroundColor="Blue"
             Title="ListaViagem"
             Icon="Menu.png">

     <StackLayout Padding="20">
        <Label Text="Menu Lateral"></Label>
     </StackLayout>
   </ContentPage>

Detail.xaml

<?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="MVVMApp.Views.Detail"
         Title="Detalhe">
</ContentPage>

These are the codes of the xamls.

Navigation codes in Mainview.CS:

        public MainView()
    {
        InitializeComponent();
        this.Master = new Master();
        this.Detail = new NavigationPage(new DetailPage());
        //this.BindingContext = new ViewModels.MainViewModel();
    }
  • Put your shampooing code on, please.

  • 1

    I posted the code of the Xamls as requested.

  • I noticed that you are adding the masterpage and detailpage through C#. When you add Contentpage that represents Detailpage, try to put it inside a Navigation page. Example: Detail = new Navigationpage(new Detailpage());

  • But that’s when I’m gonna do the navigation?

1 answer

1


I managed to solve the problem:
The error was in the navigation interface when I clicked the login button it ran the navigation function for the mainview. Line below:

     public async Task NagateToMain()
    {
        MVVMApp.App.Current.MainPage = new NavigationPage(new Views.MainView());

    }

My Main was inside a Page, as if there were two pages inside each other. To correct the change to

    public async Task NagateToMain()
    {
        MVVMApp.App.Current.MainPage = new Views.MainView();
    }

So I made the correction.
Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.