【发布时间】:2017-09-04 15:02:09
【问题描述】:
我正在尝试在 Xamarin.Forms 中构建的应用程序上为时间线实现类似卡片的记录列表,这是我或多或少需要复制的布局:
我想我已经接近了,我的代码后面有两条记录,我将它们作为 ItemSource 分配给 XAML 端的 listView,这是我迄今为止的结果:
但是正如您所看到的,元素根本没有显示在它们的框架内,如果我用 TextCells 或 ImageCells 替换表单控件,则数据显示正常。这是我到目前为止的 XAML 代码:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="AudioBitts"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AudioBitts"
x:Class="AudioBitts.TimelinePage">
<ListView x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="300">
<Frame HasShadow="true" Margin="5">
<StackLayout>
<StackLayout Orientation="Horizontal">
<Image Source="{Binding UserAvatar}" />
<Label Text="{Binding UserName}" />
</StackLayout>
<Image Source="{Binding BittImage}" />
</StackLayout>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
我在为 XAML 代码提供的结构上是否遗漏了某些内容?谢谢!
【问题讨论】:
标签: xaml listview xamarin.forms cardview