0

我已经使用了 VerticalOptions="EndAndExpand" 然后还在最后留下了空间,任何人都对此有所了解。我已经在我面临的同样问题中尝试了集合视图

这是我的页面

<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
         <ffimageloading:CachedImage Margin="10" x:Name="ImageData"
                         IsVisible="{Binding IsImageURL}"
                         IsEnabled="{Binding IsImageURL}"
                         Source="{Binding ImageURL}"
                         HeightRequest="150" WidthRequest="200"
                         HorizontalOptions="CenterAndExpand"
                         VerticalOptions="CenterAndExpand"
                         BackgroundColor="Transparent" Aspect="Fill" >
         </ffimageloading:CachedImage>

         <ListView x:Name="QuizzesAnsList" BackgroundColor="Blue"
                      ios:ListView.RowAnimationsEnabled="false"
                      VerticalOptions="EndAndExpand"
                      HorizontalOptions="FillAndExpand"
                      SelectionMode="None"
                      VerticalScrollBarVisibility="Never"
                      HasUnevenRows="True"
                      ItemsSource="{Binding QuizzesQuestionAnswersList}"
                      SeparatorVisibility="None" >
                    <ListView.ItemTemplate >
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout VerticalOptions="Fill" Orientation="Horizontal" Spacing="0" Margin="0,5,0,0">

                                    <Frame  VerticalOptions="Fill" BackgroundColor="{Binding BackgroundColor}" BorderColor="{Binding BorderColor}" HasShadow="False"  HorizontalOptions="FillAndExpand"  CornerRadius="2"  Padding="5" >
                                        <StackLayout Orientation="Horizontal" Spacing="0" VerticalOptions="Fill" HorizontalOptions="FillAndExpand" >
                                            <material:MaterialLabel Margin="5" Text="{Binding AnswerText}" HorizontalTextAlignment="Center" FontSize="17" Style="{Binding FontType,Mode=TwoWay}"                                                                  VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" TextColor="White" FontAttributes="Bold" />
                                        </StackLayout>
                                    </Frame>

                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer
                                                            Command="{Binding Path=BindingContext.SelectedQuizeAnswer, Source={x:Reference QuizzesAnsList}}"
                                                            CommandParameter="{Binding .}"/>
                                    </StackLayout.GestureRecognizers>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
         </ListView>
</StackLayout>
4

1 回答 1

1

我在您的代码中发现了问题。实际上,TheListView已经占据了整个页面。如果您的列表项是静态的,则HeightRequest="100"在您的ListView或您的列表项中设置为动态使用BindableLayout

<StackLayout x:Name="QuizzesAnsList" BindableLayout.ItemsSource="{Binding QuizzesQuestionAnswersList}"  VerticalOptions="EndAndExpand" HorizontalOptions="FillAndExpand">
            <BindableLayout.ItemTemplate>
                <DataTemplate>
                    <StackLayout VerticalOptions="Fill" Orientation="Horizontal" Spacing="0" Margin="0,5,0,0">
                                    <Frame  VerticalOptions="Fill" BackgroundColor="{Binding BackgroundColor}" BorderColor="{Binding BorderColor}" HasShadow="False"  HorizontalOptions="FillAndExpand"  CornerRadius="2"  Padding="5" >
                                        <StackLayout Orientation="Horizontal" Spacing="0" VerticalOptions="Fill" HorizontalOptions="FillAndExpand" >

                                            <material:MaterialLabel Margin="5" Text="{Binding AnswerText}" HorizontalTextAlignment="Center" FontSize="17" Style="{Binding FontType,Mode=TwoWay}"
                                                                        VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" TextColor="White" FontAttributes="Bold" />
                                        </StackLayout>

                                    </Frame>

                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer
                                                            Command="{Binding Path=BindingContext.SelectedQuizeAnswer, Source={x:Reference QuizzesAnsList}}"
                                                            CommandParameter="{Binding .}"/>
                                    </StackLayout.GestureRecognizers>
                                </StackLayout>

                </DataTemplate>
            </BindableLayout.ItemTemplate>
        </StackLayout>
于 2020-02-07T11:25:15.273 回答