有人可以帮我一点Xamarin吗? 我们如何在Xamarin的主细节页面中添加导航栏和页面按钮? 我添加了一个MasterDetail页面,并按如下方式定义了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: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>
我错过了什么吗?
提前致谢
答案 0 :(得分:1)
尝试在NavigationPage中包装“详细信息”页面:
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<local:MainPage/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
那应该会在顶部给你一个导航栏。