我一直为此苦苦挣扎。我有一个简单的列表视图,该视图使用数据模型提取数据。我要做的就是在背景中放一个与屏幕大小相同的图像
<ContentPage Padding="0,-20,0,0" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="xxxxxxxx.Pages.PrayersByCategory">
<ContentPage.Content>
<ListView RowHeight="55" x:Name="lv_prayers_categories_page" VerticalOptions="FillAndExpand" HasUnevenRows="false" SelectedItem="Handle_ItemSelected" BackgroundColor="Transparent" SeparatorVisibility="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid x:Name="cellGrid" Padding="15">
<Grid.ColumnDefinition></Grid.ColumnDefinition>
<Label x:Name="lblPrayerCategory" Text = "{Binding prayerCategory}" FontSize="16" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
<Label x:Name="lblPrayerCount" Text = "{Binding prayerCategoryID}" FontSize="16" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2"/></Grid></ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
答案 0 :(得分:2)
如果列表视图填充了页面,则可以设置 ContentPage 背景颜色:
<ContentPage Padding="0,-20,0,0"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="xxxxxxxx.Pages.PrayersByCategory"
BackgroundImage="star_outline.png">