Anu Viswan
Anu Viswan

Reputation: 18155

Navigation bar and Page Buttons missing in Master Details Page

Could someone help me with a bit of Xamarin. How do we add Navigation Bar and Page Buttons in a Master Detail Page in Xamarin ? I added a MasterDetail page, and defined the xaml as follows.

<?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:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                  xmlns:local="clr-namespace:MyNameSpace.Views;assembly=MyNameSpace"
                  prism:ViewModelLocator.AutowireViewModel="True"
                  x:Class="MyNameSpace.Views.MainMenu">
  <MasterDetailPage.Master BackgroundColor ="White">
    <ContentPage Title="Master Page"  BackgroundColor = "#2c3e50" >
<Grid BackgroundColor ="#354b60">
    <Grid.RowDefinitions>
      <RowDefinition Height="*"  />
      <RowDefinition Height="3*" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
<StackLayout Grid.Row="1" Grid.Column="0">
          <Button BackgroundColor="#2c3e50" TextColor="White" Text="Menu 1"  ></Button>
          <Button BackgroundColor="#2c3e50" TextColor="White" Text="Menu 2"  ></Button>
        </StackLayout>
</Grid>



    </ContentPage>
  </MasterDetailPage.Master>
  <MasterDetailPage.Detail>
    <local:MainPage/>
  </MasterDetailPage.Detail>
</MasterDetailPage>

Am I missing out something ?

Thanks in advance

Upvotes: 0

Views: 1248

Answers (1)

jgoldberger - MSFT
jgoldberger - MSFT

Reputation: 6088

Try wrapping your Detail page in a NavigationPage:

<MasterDetailPage.Detail>
    <NavigationPage>
        <x:Arguments>
            <local:MainPage/>
        </x:Arguments>
    </NavigationPage>
</MasterDetailPage.Detail>

That should give you a navigation bar at the top.

Upvotes: 1

Related Questions