我正在與Xamarin形式的應用程序。我希望應用顯示類似於YouTube的列表視圖。左側有一個縮略圖,右側有一個視頻標題,下方有詳細信息。目前,我只能將細節放在一行上。圖片小區內的多個結合形式的XAML
我該如何將細節分成多個圖像單元格內的行?
目前:
Homepage.xaml:
<StackLayout Orientation="Vertical">
<SearchBar x:Name="MainSearchBar" HorizontalOptions="Center" />
<ListView x:Name="VideoList" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell Text = "{Binding Title}" Detail="{Binding Detail}" ImageSource="{Binding ImageURL}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
Videos.cs:
class Videos
{
public string Title { get; set; }
public string Author { get; set; }
public int Views { get; set; }
public DateTime Upload_DateTime { get; set; }
public string ImageURL { get; set; }
public string Detail
{
get
{
return string.Format("{0} - {1} Views Uploaded: {2} ", Author, Views, Upload_DateTime); //format for details on imagecell
}
}
}
注:我曾嘗試以下格式上Videos.cs:
return string.Format("{0} - {1} Views \nUploaded: {2} ", Author, Views, Upload_DateTime);
return string.Format("{0} - {1} Views
Uploaded: {2} ", Author, Views, Upload_DateTime);
您需要使用ViewCell和定義自己的佈局,而不是使用預定義的ImageCell – Jason