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

AsifMayilliAsifMayilli USMember
edited November 2016 in Cross Platform with Xamarin

Hi people. 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>

</MasterDetailPage>

`

Best Answer

Answers

  • AsifMayilliAsifMayilli USMember

    @Neocomer thanks. It works fine. But what about TitleIcon instead of text title? Lets say for example instead of Paid invoice put logo.

  • NeocomerNeocomer GBMember ✭✭
    edited November 2016

    You would need to create a custom renderer for that. As for how to go about that. i can't say i'm too sure. i tend to run away from custom renders.
    Try this to get the page icon which if i remember loads near the text
    NavigationPage.SetTitleIcon(this, fileName);

  • freezer27freezer27 Member ✭✭
    edited June 2019

    You can customize the Bar in XAML without f#cking custom renders:

    <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal">
                <Image Source="IconOrImageHere">
                </Image>
                <Label
                   Text="Title here"
                   FontSize="18"
                   TextColor="White"
                   VerticalTextAlignment="Center" />
            </StackLayout>
        </NavigationPage.TitleView>
    
Sign In or Register to comment.