Search code examples
xamarin.formstoolbarcenter

Xamarin Forms: How to align the contentPage toolbar image to center?


I have added an icon to the toolbar by the following code, but how can I align it to center. Now it is on the right end. In this thread telling it is not possible in xamarin forms.

<ContentPage.ToolbarItems>
    <ToolbarItem Icon="logo-final.jpg"/>
</ContentPage.ToolbarItems>

I need the icon on the center like below screen.

enter image description here

Please suggest a solution for this feature?


Solution

  • You should try Navigation Title view

    <ContentPage>
        <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10">
                <Image Source="iconXamagon.png">               
                </Image>           
            </StackLayout>
        </NavigationPage.TitleView>
        ...
    </ContentPage>
    

    For more referance https://montemagno.com/xamarin-forms-icons-in-navigation-toolbar/