问题
I am creating a master detail page in Xamarin Forms. I want to have Menu icon on top left, searcher on the right and another label on the menu bar.
Can some help help me with how I can be done? I added the menu icon. I want help with adding other controls on the toolbar/Menubar/Navigation bar what ever it is called. Its the bar on top of the master detail page.
Code:
<?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:PCL.Core.Views;assembly=PCL.Core"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="PCL.Core.Views.RootPage" MasterBehavior="Popover" >
<MasterDetailPage.Master>
<local:MasterPage/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage BarBackgroundColor="Maroon" >
<x:Arguments >
<local:DetailPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
Thanks.
回答1:
If you talking about this kind of controls as on image than:
"Hamburger menu" image you set in MasterDetail page; Icons (GPS and DATA on image) - are ToolbarItem's that you need to add to Detail Page
There is plenty of examples available:
https://forums.xamarin.com/discussion/17339/navigationpage-and-toolbaritems
https://forums.xamarin.com/discussion/17351/making-a-toolbar
来源:https://stackoverflow.com/questions/40615109/xamarin-forms-how-to-add-controls-on-masterdetail-tool-bar