如何创建简单的汉堡菜单或菜单navegation

时间:2017-05-30 15:15:15

标签: xamarin

我有以下命令,但我无法调用菜单导航或简单的汉堡包菜单,我已经准备好了xaml我有app.cs,如何在我的主页面调用菜单

注意:我的项目是跨平台(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>

1 个答案:

答案 0 :(得分: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;