如何将TitleIcon和按钮添加到NavigationPage导航栏?
我想添加TitleIcon并重新加载按钮导航栏的NavigationPage,但不知道该怎么做。我试图使用图标属性的导航页面,但它不起作用。关于添加按钮到导航页面,我还没有找到任何东西。如何将TitleIcon和按钮添加到NavigationPage导航栏?
<?xml version="1.0" encoding="UTF-8"?> <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.MasterDetailMenu"
xmlns:local="clr-namespace:App;assembly=App">
<MasterDetailPage.Master>
<local:MasterPage/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail >
<NavigationPage BarBackgroundColor="#7FBE5D" x:Name="NavBar" Icon="image.png">
<x:Arguments>
<local:Feedbacks/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
回答:
[XamlCompilation(XamlCompilationOptions.Compile)] public partial class AboutPage : ContentPage
{
public AboutPage()
{
InitializeComponent();
NavigationCommand = new Command(NavigationCommandToInfo);
ToolbarItems.Add(new ToolbarItem() { Icon = "Info2.png", Command=NavigationCommand });
}
public ICommand NavigationCommand { get; }
void NavigationCommandToInfo() =>
Navigation.PushAsync(new MainPage());
}
以上是 如何将TitleIcon和按钮添加到NavigationPage导航栏? 的全部内容, 来源链接: utcz.com/qa/264919.html