0

我想添加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> 

+0

您是否嘗試過推頁面模態?這樣做[將允許您添加項目,如圖標,到您的工具欄](http://stackoverflow.com/questions/30733917/xamarin-forms-show-cancel-button-in-toolbar-items-instead-的回-IOS/30968945#30968945)。 – Demitrian

+0

@Demitrian謝謝!它工作得很好))) –

+0

很高興知道:)記得要upvote,如果你同意的解決方案;) – Demitrian

回答

1
[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()); 
}