我正在处理Xamarin顶部菜单,当前正在选择菜单文本,它会显示页面列表。但是我有点迷失了如何更改它以使用HamburgerMenu图标。我添加了按钮图像控件,但它不会替换菜单文本。
enter code here
>是否需要在mainPage.xaml中添加它?
MainPage.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:pages="clr-namespace:ReimbursementApp.Pages"
x:Class="ReimbursementApp.Pages.MainPage"
xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives">
<MasterDetailPage.Master>
<pages:MenuPage />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<pages:ItemsPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
menupage.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="ReimbursementApp.Pages.MenuPage"
xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
xmlns:telerik="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
Title="Menu">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackLayout Orientation="Horizontal" Spacing="10">
<Button WidthRequest="32" HeightRequest="32" BorderWidth="0" BorderRadius="0"
BorderColor="Transparent" BackgroundColor="Transparent">
<Button.Image>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS,Android">HamburgerMenu.png</On>
</OnPlatform>
</Button.Image>
</Button>
<Label VerticalOptions="Center" Text="Testing App" />
</StackLayout>
<StackLayout VerticalOptions="FillAndExpand">
<ListView x:Name="ListViewMenu"
HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="10">
<Label Text="{Binding Title}" FontSize="20"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</Grid>
</ContentPage>