0

I have the following command but I am not able to call the menu navagation or simple hamburger menu, I have already the ready xaml I have my app.cs, how to call the menu in my main page

Note: my project is cross plataform (IOS, Android, WP)

 public class App : Application
{

public App()
{
    MainPage = new NavigationPage(new MainTabbedPage() { Title = "Titulo Topo" });
}

public class MainTabbedPage : TabbedPage
{
    public MainTabbedPage()
    { 
        Children.Add(new AboutPage_1() { Title = "Titulo 1" });
        Children.Add(new AboutPage_2() { Title = "Titulo 2" });
        Children.Add(new AboutPage_3() { Title = "Titulo 3" });
        Children.Add(new AboutPage_4() { Title = "Titulo 4" });
        Children.Add(new AboutPage_5() { Title = "Titulo 5" });
        Children.Add(new AboutPage_6() { Title = "Titulo 6" });
    }
}

MenuPage

<?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="Hanselman.Portable.Views.MenuPage"
xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
Title="{Binding Title}"
Icon="{Binding Icon}">
 <ContentPage.Content>
   <StackLayout VerticalOptions="FillAndExpand">
     <ListView 
            CachingStrategy="RecycleElement"
            HasUnevenRows="True"
            x:Name="ListViewMenu">
            <ListView.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="10"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="80"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="5"/>
                    </Grid.RowDefinitions>

                    <BoxView Grid.ColumnSpan="3" 
                             Grid.RowSpan="4"
                             BackgroundColor="#234084"/>
                    <Label 
                        Grid.Column="1"
                        Grid.Row="2"
                        Text="Titulo"
                        TextColor="White"
                        FontSize="30"
                        Style="{DynamicResource SubtitleStyle}"/>
                </Grid>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid Padding="12">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <!--<Image Source="{Binding Icon}" HeightRequest="25" WidthRequest="25"/>-->
                            <Label Grid.Column="1" Text="{Binding Title}" FontSize="18"/>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
   </StackLayout>
</ContentPage.Content>

Sabino
  • 21
  • 9
  • use a Master Detail page: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/master-detail-page/ – Jason May 30 '17 at 15:19
  • With that comes another problem, how to put TabbedPage inside my masterpage? – Sabino May 30 '17 at 15:33
  • You would typically make the DetailPage (not Master) a tabbed page. What problem are you having with this? – Jason May 30 '17 at 15:46
  • Sorry, I gave it a main page, but really MasterDetailPage, I can not put tabbebpages inside the MasterDetailPage – Sabino May 30 '17 at 16:42
  • you are saying "can not" without giving any detail about what specifically you've tried or what sorts of errors you're getting. See https://stackoverflow.com/questions/38662871/tabbed-page-inside-master-detail-page-xamarin – Jason May 30 '17 at 16:50
  • Do you have any examples via command? Without using xaml – Sabino May 30 '17 at 16:55
  • see answer below – Jason May 30 '17 at 16:59

1 Answers1

0
var tabs = new TabbedPage();
tabs.Children.Add(new ContentPage { Title = "TabA" });
tabs.Children.Add(new ContentPage { Title = "TabB" });
tabs.Children.Add(new ContentPage { Title = "TabC" });

this.Master = new ContentPage { Title = "Master" };
this.Detail = tabs;
Jason
  • 86,222
  • 15
  • 131
  • 146
  • error: System.InvalidOperationException: Master and Detail must be set before adding MasterDetailPage to a container – Sabino May 30 '17 at 17:34