【发布时间】:2018-08-28 11:46:12
【问题描述】:
我有一个 ListView,需要堆叠在另一个水平 Stack 布局下。无论我做什么,ListView 似乎都与它上面的所有内容重叠。我需要它没有这种行为并实际显示上面的布局。我只是不知道如何,任何帮助将不胜感激。
我也尝试将两者放在一个网格中,并且确实设法释放顶部的空间,但仍然没有显示任何测试标签。
如上所示,ListView 只是与它上方的内容(带有标签的堆栈布局)重叠,并且在 Aaron 上方屏幕外显示两个条目。
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="engME.YourFullNamesListPage">
<StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Test 1" HorizontalTextAlignment="Center"/>
<Label Text="Test 2" HorizontalTextAlignment="Center"/>
<Label Text="Test 3" HorizontalTextAlignment="Center"/>
<Label Text="Test 4" HorizontalTextAlignment="Center"/>
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="FillAndExpand">
<ListView x:Name="FullNamesList" VerticalOptions="FillAndExpand" RowHeight="50">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.1*"/>
<ColumnDefinition Width=".3*"/>
</Grid.ColumnDefinitions>
<Label FontSize="Large"
FontAttributes="Bold"
HorizontalTextAlignment="Start"
Margin="20,0,0,0"
VerticalTextAlignment="Center"
Grid.Row="0"
Grid.Column="0">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="F">
<Setter Property="Text" Value="{Binding Name}"/>
<Setter Property="TextColor" Value="#cc0066"/>
</DataTrigger>
<DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="M">
<Setter Property="Text" Value="{Binding Name}"/>
<Setter Property="TextColor" Value="#007acc"/>
</DataTrigger>
<DataTrigger TargetType="Label" Binding="{Binding Gender}" Value="A">
<Setter Property="Text" Value="{Binding Name}"/>
<Setter Property="TextColor" Value="#00994d"/>
</DataTrigger>
</Label.Triggers>
</Label>
<Label Text="{Binding ShortMeaning}"
FontSize="Small"
TextColor="Gray"
VerticalTextAlignment="Center"
Grid.Row="0"
Grid.Column="1">
</Label>
<Image Source="favorite.png"
Grid.Row="0"
Grid.Column="2"
Scale=".7">
</Image>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage>
【问题讨论】:
-
你的 iPhone 是什么版本?我使用类似的代码,但没有这样的问题。
标签: c# xamarin xamarin.forms xamarin.ios