2016-09-21 57 views
0

编辑:我能够通过在ListView中添加“HasUnevenRows =”True来解决问题,不知道为什么它可以工作,但是,嘿,问题消失了; dListview - > ViewCell - > StackLayout:不是整个内容显示出来

EDIT2:从docs

应用程序开发者会发现,最容易和最不容易出错的方式来自动为内容大小列表视图中的行是:首先,要设置的ListView .HasUnevenRows属性为true;

我实现以下列表视图:ListView控件在C#

<ListView x:Name="ListView" 
         IsPullToRefreshEnabled="True" 
         ItemSelected="ListView_ItemSelected" 
         Refreshing="ListView_Refreshing"> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <ViewCell> 
          <StackLayout Orientation="Vertical"> 
           <Image HorizontalOptions="Center" Source="{Binding MyObjectValue1, Converter={StaticResource Base64ToImageConverter}}" /> 
           <Label FontAttributes="Bold" Text="{Binding MyObjectValue2}" /> 
           <Label Text="{Binding MyObjectValue3}" /> 
          </StackLayout> 
         </ViewCell> 
        </DataTemplate> 
       </ListView.ItemTemplate> 
      </ListView> 

内容:

ListView.ItemsSource = listOfMyObject; 

注:图片是加工精细,无关于worrys。

问题:当我部署我的应用程序时,只有图像显示在正常大小的listview-cell中。两个实验室不可见。我想达到的目标:

------------------ 
|  Pic  | 
|  Label1 | 
|  Label2 | 
|    | 
| Next List Entry| 
|  ...  | 
------------------ //Yes it is a small phone with the shape of a square cuz I am lazy ;D 

我该如何做到这一点?

干杯!

+0

我发现的东西,它似乎是你想要的! [这里](https://developer.xamarin.com/guides/xamarin-forms/working-with/images/) –

+1

谢谢!但是我遇到了一些问题:我有一个StackLayout(HeightRequest =“300”),里面有Aspect =“AspectFit”的图片。问题是,该图像不适合父级( - > StackLayout)。 – jdstaerk

回答

0

试试这个:

 <ViewCell> 
      <StackLayout Orientation="Vertical"> 
      <Image Aspect="Fill" HorizontalOptions="Center" Source="{Binding MyObjectValue1, Converter={StaticResource Base64ToImageConverter}}" /> 
      <StackLayout Orientation="Vertical">        
      <Label FontAttributes="Bold" Text="{Binding MyObjectValue2}" /> 
      <Label Text="{Binding MyObjectValue3}" /> 
      </StackLayout> 
      </StackLayout> 
     </ViewCell>