2015-04-28 76 views
0

我一直試圖讓Xaml(x.forms)看起來很正確,但無法讓它工作。任何可能的方式,這可以解決在Xaml沒有自定義單元格渲染器?iOS上的Xamarin.Forms ListView ViewCell問題

下面是它應該如何看待機iOS:

enter image description here

什麼我越來越至今在XAML:

enter image description here

這裏是我的XAML:

<ScrollView> 
    <StackLayout> 
     <ActivityIndicator IsRunning="{Binding IsFetching}" /> 
     <ListView ItemsSource="{Binding Events}" Header="2015" Footer=""> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <ViewCell Height="55"> 
         <ViewCell.View> 
          <StackLayout Orientation="Horizontal" Padding="5" BackgroundColor="White">               
           <StackLayout> 
            <BoxView WidthRequest="44" 
             HeightRequest="5" 
             BackgroundColor="Purple" 
             /> 
            <Label Text="AUG" FontSize="12" HeightRequest="13" HorizontalOptions="Center" VerticalOptions="Start" FontAttributes="Bold"/> 
            <Label Text="31" FontSize="13" VerticalOptions="StartAndExpand" HorizontalOptions="Center" /> 
           </StackLayout>        
           <StackLayout Orientation="Vertical" 
              HorizontalOptions="StartAndExpand"> 
            <Label Text="Relay For Life of" FontSize="14" VerticalOptions="End" TextColor="Gray"/> 
            <Label Text="Hope City" FontSize="16" FontAttributes="Bold" VerticalOptions="StartAndExpand"/> 
           </StackLayout> 
          </StackLayout> 
         </ViewCell.View> 
        </ViewCell>   
       </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 
    </StackLayout> 
</ScrollView> 

回答

2

你可以用G擺脫,而不是堆棧,還增加的rowHeight到您的ListView

<ListView ... RowHeight="55"> 
... 
<ViewCell Height="55"> 
    <Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="44"/> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="44"/> <!-- for the checkmark --> 
    </Grid.ColumnDefinitions> 
    <Grid Grid.Column="0"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="5" /> 
      <RowDefinition Height="22" /> 
      <RowDefinition Height="17" /> 
     </Grid.RowDefinitions> 
     <BoxView Grid.Row="0" WidthRequest="44" HeightRequest="5" BackgroundColor="Purple"/> 
     <!-- experiment with the vertical alignment to get it right --> 
     <Label Grid.Row="1" Text="AUG" .../> 
     <Label Grid.Row="2" Text="31" .../> 
    </Grid> 
<Grid Grid.Column="0"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="22" /> 
      <RowDefinition Height="22" /> 
     </Grid.RowDefinitions> 
     <!-- if the vertical alignment doesn't work well add two more rows for top and bottom padding --> 
     <Label Grid.Row="0" Text="Relay for life" VerticalOptions="End" .../> 
     <Label Grid.Row="1" Text="Hope city" VerticalOptions="Start" .../> 
    </Grid> 
    </Grid> 
</ViewCell> 
0

設置HasUnevenRows = 「真」 上的ListView

相關問題