2017-09-28 6 views
0

私はXamarinフォームのクロスプラットフォームアプリケーションに取り組んでいます。私はリストビューでデータを表示する必要があるフォームを持っています。xamarin形式のリストビューは、フォームのフルスペースを使用していません

データは表示されていますが、スペース全体を使用していないため、下部に不要なスペースが残っています。

enter image description here

<?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="BMTHomesApp.Views.ImportantAppointments"> 
    <ContentPage.Content> 
     <StackLayout VerticalOptions="StartAndExpand"> 
      <ListView HasUnevenRows="True" RowHeight="100" HeightRequest="-1" x:Name="ListViewAppointments" VerticalOptions="StartAndExpand"> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <ViewCell> 
          <Grid Padding="20,0,0,0" ColumnSpacing="20"> 
           <Grid.RowDefinitions> 
            <RowDefinition Height="40"></RowDefinition> 
            <RowDefinition Height="40"></RowDefinition> 
           </Grid.RowDefinitions> 
           <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="40"></ColumnDefinition> 
            <ColumnDefinition Width="*"></ColumnDefinition> 
           </Grid.ColumnDefinitions> 

           <!--<BoxView Color="#f7f7f7" Grid.Column="0" Grid.RowSpan="2"/> 
           <BoxView Color="#ffffff" Grid.Column="1" Grid.RowSpan="2"/>--> 
           <Image Grid.RowSpan="2" Grid.Column="0" x:Name="ImageAppointmentIcon" Source="AppointmentsIcon.png" Aspect="AspectFit"></Image> 
           <Label TextColor="#00344e" FontAttributes="Bold" Text="{Binding Subject}" Grid.Row="0" Grid.Column="1" VerticalTextAlignment="End"></Label> 
           <Label TextColor="#0073ae" Text="{Binding StartDate}" Grid.Row="1" Grid.Column="1" VerticalTextAlignment="Start"></Label> 
          </Grid> 
         </ViewCell> 
        </DataTemplate> 
       </ListView.ItemTemplate> 
      </ListView> 
      <ActivityIndicator x:Name="ActLoder" HorizontalOptions="CenterAndExpand" Color="#ffffff" VerticalOptions="CenterAndExpand" /> 
     </StackLayout> 
    </ContentPage.Content> 
</ContentPage> 

答えて

1

は、ListViewの後ActivityIndi​​catorだろう次のように私のXAMLです。それらはStackLayout内に囲まれているため、両方とも垂直方向にスペースを取ることになります。

ActivityIndi​​catorをListViewの上部に表示する場合は、StackLayoutをGridに置き換えます。

HeightRequest = -1とは何かがわかりません。

+0

私は= HeightRequestを設定-1参照してください:あなたはActivityIndicatorListviewと同じスペースに表示したいが、その後、あなたが次のことを試すことができ中心場合ActivityIndicator

の岩下Listviewを積み重ねていますこれを使用するかどうかはフォームの高さを使用しますが動作しませんでした...また、アクティビティインジケータを削除しても同じ結果を返します – Mahajan344

+0

アクティビティインジケータとスタックレイアウトの両方を取り除き、リストビューが全てのページ。また、HasUnevenRows = trueまたはRowHeight = 100のどちらかを設定する必要があります。両方を必要としません。 –

+0

おそらくRowHeight = 100で、行の高さがどのようにハードコードされているかが分かります。 –

0

私はStackLayoutがあなたのレイアウトの問題を引き起こしていると思います。

<ContentPage.Content> 
    <Grid> 
     <ListView HasUnevenRows="True" RowHeight="100" x:Name="ListViewAppointments" VerticalOptions="StartAndExpand"> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <ViewCell> 
         <Grid Padding="20,0,0,0" ColumnSpacing="20"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="40"></RowDefinition> 
           <RowDefinition Height="40"></RowDefinition> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="40"></ColumnDefinition> 
           <ColumnDefinition Width="*"></ColumnDefinition> 
          </Grid.ColumnDefinitions> 

          <!--<BoxView Color="#f7f7f7" Grid.Column="0" Grid.RowSpan="2"/> 
          <BoxView Color="#ffffff" Grid.Column="1" Grid.RowSpan="2"/>--> 
          <Image Grid.RowSpan="2" Grid.Column="0" x:Name="ImageAppointmentIcon" Source="AppointmentsIcon.png" Aspect="AspectFit"></Image> 
          <Label TextColor="#00344e" FontAttributes="Bold" Text="{Binding Subject}" Grid.Row="0" Grid.Column="1" VerticalTextAlignment="End"></Label> 
          <Label TextColor="#0073ae" Text="{Binding StartDate}" Grid.Row="1" Grid.Column="1" VerticalTextAlignment="Start"></Label> 
         </Grid> 
        </ViewCell> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 
     <ActivityIndicator x:Name="ActLoder" HorizontalOptions="CenterAndExpand" Color="#ffffff" VerticalOptions="CenterAndExpand" /> 
    </Grid> 
</ContentPage.Content> 
関連する問題