Mighty Codder
Mighty Codder

Reputation: 91

How to add TitleIcon and button to navigation bar of NavigationPage?

I am trying to add TitleIcon and reload button to Navigation Bar of NavigationPage but dont know how to do it. I tried to use Icon property for navigation page but it does not work. About adding buttons to navigationpage i have not found anything.

<?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>

Upvotes: 0

Views: 2366

Answers (1)

Buddhima Kudagama
Buddhima Kudagama

Reputation: 63

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

Upvotes: 2

Related Questions