看起来像这样
我一直在研究医疗应用,并使用MasterDetailPage将所有导航放到一个地方。但它太多了,所以我想把它分成一个。我想到了每个页面项目的下拉菜单。我一直在网上搜索实现它,但我无法弄明白。这是Android上的Xamarin,我想做一个类似于上图的下拉菜单。
这是我目前在C#上的代码
namespace MasterDetailPageNavigation
{
public partial class MasterPage : ContentPage
{
public ListView ListView { get { return listView; } }
public MasterPage ()
{
InitializeComponent ();
BackgroundColor = Color.FromHex ("ffffff");
var masterPageItems = new List<MasterPageItem> ();
masterPageItems.Add (new MasterPageItem {
Title = "DashBoard",
TargetType = typeof(DashBoard)
});
masterPageItems.Add (new MasterPageItem {
Title = "Schedules",
TargetType = typeof(SchedulesCS)
});
masterPageItems.Add (new MasterPageItem {
Title = "Master Data",
TargetType = typeof(MasterDataCS)
});
masterPageItems.Add (new MasterPageItem {
Title = "Audit Trail",
TargetType = typeof(AuditTrailCS)
});
listView.ItemsSource = masterPageItems;
}
}
}
对于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="MasterDetailPageNavigation.MasterPage"
Padding="0,40,0,0"
Icon="hamburger.png"
Title="Medical">
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand">
<ListView x:Name="listView" VerticalOptions="FillAndExpand" SeparatorVisibility="None">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell Text="{Binding Title}" ImageSource="{Binding IconSource}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
你是怎么做到的?