2017-07-30 92 views
0

我想用帶有黃色背景的單元格和一個帶有文本的橙色框以及中等大小的圖像執行操作,但不起作用。圖像不會出現大的,我不能用保證金單元格不顯示完整圖像

這是我的XAML

<?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="neoFly_Montana.Views.PromocoesView" 
     BackgroundImage="promocoesbackground" 
     Title="Promoções"> 
<ContentPage.Content> 
    <ListView x:Name="listview_promocoes" Margin="0, 20, 0, 0 "> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
       <ViewCell> 

        <StackLayout BackgroundColor="AliceBlue" HorizontalOptions="Center" VerticalOptions="FillAndExpand"> 
         <Label Text="{Binding titulo}" Style="{StaticResource labelsfont}"/> 

         <Image Source="{Binding imagem}" Aspect="AspectFill"/> 
        </StackLayout> 


       </ViewCell> 


      </DataTemplate> 
     </ListView.ItemTemplate> 
    </ListView> 


</ContentPage.Content> 

這是壞的結果(含2項 - 你無法看到圖像)

enter image description here

我想要做這樣的事情,而是因爲當我使用它,應用程序不工作,我不能使用保證金。

enter image description here

它需要一個ListView的一個項目。 所有項目應該是這樣的。

我該怎麼做? 謝謝。

回答

2

你可以在你的ListView項是佈局像這樣的東西:

<ListView 
     RowHeight="170" 
     ItemsSource="{Binding Items}"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
     <ViewCell> 
      <!-- Outter box containing two boxes --> 
      <StackLayout 
         VerticalOptions="FillAndExpand"> 
       <!-- First box with Title, Image and Text --> 
       <StackLayout 
          VerticalOptions="FillAndExpand" 
          Padding="10, 5" 
          BackgroundColor="Yellow"> 
        <Label 
          Text="YOUR_TITLE" 
          BackgroundColor="Silver"/> 
        <Image 
          HorizontalOptions="FillAndExpand" 
          BackgroundColor="Fuchsia" 
          HeightRequest="60" /> 
        <Label 
          Text="YOUR_OTHER_TEXT" 
          BackgroundColor="Silver"/> 
       </StackLayout> 

       <!-- Second box with Text --> 
       <StackLayout 
          VerticalOptions="End" 
          Margin="0, 8, 0, 0" 
          Padding="10, 5" 
          BackgroundColor="Lime"> 
        <Label 
          Text="YOUR_TEXT_OTHER_BOX" 
          BackgroundColor="Silver"/> 
       </StackLayout> 
      </StackLayout> 
     </ViewCell> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 

我猜你可能需要做一些小的改變,只要你想,但,這是非常接近得到它到底。

結果:

enter image description here

希望這helps.-

+0

我用它,但我的心不是像大再次..像我這裏貼的照片。你可以 只看到我的應用程序中的圖片的一小部分:/ 我不知道發生了什麼... –

+0

它似乎是一行...在我的應用程序似乎行:/ –

+0

現在它的工作 謝謝非常 –

相關問題