Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a BackgroundImage to a ListView in Xamarin Forms?

I am aware that there is no property called BackgroundImage for the ListView class - only the BackgroundColor property but that is not what I am looking for. Is there a way to add a background image to the ListView so that when I scroll the image stays in place and the tiles simply 'move' over the image as you scroll.

Adding the image to the ContentPage also does not work since the ListView simply overlays it.

like image 462
Loupi Avatar asked Jun 13 '17 14:06

Loupi


1 Answers

Your post is really good, you just miss a doble quotations marks on the Source property

Set your ListView's BackgroundColor to Transparent:

<RelativeLayout>
    <Image Source="background.png" 
        BackgroundColor="Transparent" 
        VerticalOptions="CenterAndExpand" 
        HorizontalOptions="CenterAndExpand"/>
    <ListView x:Name="listView" 
        VerticalOptions="CenterAndExpand"
        HorizontalOptions="CenterAndExpand"
        BackgroundColor="Transparent"
              ItemTapped="OnItemTapped"
              ItemsSource="{Binding .}" />
</RelativeLayout>
like image 112
SushiHangover Avatar answered Oct 22 '22 23:10

SushiHangover