2017-05-31 14 views
1

我正在與Xamarin形式的應用程序。我希望應用顯示類似於YouTube的列表視圖。左側有一個縮略圖,右側有一個視頻標題,下方有詳細信息。目前,我只能將細節放在一行上。圖片小區內的多個結合形式的XAML

我該如何將細節分成多個圖像單元格內的行?

目前:

enter image description here

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&#x0a;Uploaded: {2} ", Author, Views, Upload_DateTime);

+2

您需要使用ViewCell和定義自己的佈局,而不是使用預定義的ImageCell – Jason

回答

0

感謝@Jason!

現在我有一個網格佈局裏的一個視圖單元格。這似乎正是我需要的!接下來,我將需要更正格式以使其看起來更漂亮,但大部分情況下,這個問題已得到解答!

enter image description here

Homepage.xaml:

<StackLayout Orientation="Vertical"> 
    <SearchBar x:Name="MainSearchBar" HorizontalOptions="Center" /> 
    <ListView x:Name="VideoList" HasUnevenRows="True"> 
     <ListView.ItemTemplate> 
      <DataTemplate> 

       <ViewCell> 
        <ViewCell.View> 
         <Grid> 
          <Grid.RowDefinitions> 
           <RowDefinition/> 
           <RowDefinition/> 
           <RowDefinition/> 
          </Grid.RowDefinitions> 

          <Grid.ColumnDefinitions> 
           <ColumnDefinition/> 
           <ColumnDefinition/> 
          </Grid.ColumnDefinitions> 

          <Image Source="{Binding ImageURL}" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3"/> 
          <Label Text="{Binding Title}" Grid.Row="0" Grid.Column="1"/> 
          <Label Text="{Binding Author_Views}" Grid.Row="1" Grid.Column="1"/> 
          <Label Text="{Binding Uploaded}" Grid.Row="2" Grid.Column="1"/> 
         </Grid> 
        </ViewCell.View> 
       </ViewCell> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
    </ListView> 
</StackLayout> 
+1

確定,標誌的問題爲已回答 –