0

Is there any way to add background Image on navigationbar page by page on xamarin forms?

This must change every page

magicandre1981
  • 27,895
  • 5
  • 86
  • 127

1 Answers1

0

The would need to write a custom render to change the background of the navigation bar. This is simply because the navigation bar does not have an option to change the background image.

https://books.google.co.uk/books/about/Xamarin_Forms_Solutions.html?id=wvt9DwAAQBAJ&printsec=frontcover&source=kp_read_button&redir_esc=y#v=onepage&q&f=false

There's a good very brief section about how to write custom renders is this ^ book (you can even find it in the preview without purchasing it).

An alternative solution would be to create a custom banner at the top of the page

https://forums.xamarin.com/discussion/126227/customizing-navigation-bar-or-action-bar-in-xamarin-forms[As mentioned in this answer2

<ContentPage NavigationPage.HasNavigationBar="false">
    <StackLayout VerticalOptions="Start" 
                               HorizontalOptions="FillAndExpand" 
                               Orientation="Horizontal"          
                               Padding="10,5,10,5>
        <Image HorizontalOptions="StartAndExpand" source="yourimage.png"/>
        <Label HorizontalOptions="CenterAndExpand" Text="ALL"/>
        <Image HorizontalOptions="EndAndExpand" source="yourimage.png"/>
    </StackLayout>
    <StackLayout>
        <!-- Place your code for page body-->
    </StackLayout>
</ContentPage>

I've copied the code into here for simplicity and reference. This solution removes the navigation bar and allows you to create a custom banner on each page in XAML. In here you can change the layout as you please.