Xaml 在xamarin.forms列表视图中使用滚动条

Xaml 在xamarin.forms列表视图中使用滚动条,xaml,xamarin.forms.listview,Xaml,Xamarin.forms.listview,我在listview中返回了大约20行数据,它只显示了12行。 如何在下面的listview中引入滚动条。我试着在它周围放一个滚动视图,但没有成功 <StackLayout Grid.Column="1" Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Padding="0" Spacing="0">

我在listview中返回了大约20行数据,它只显示了12行。 如何在下面的listview中引入滚动条。我试着在它周围放一个滚动视图,但没有成功

     <StackLayout Grid.Column="1" Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Padding="0" Spacing="0">
                            <SearchBar x:Name="searchBar" Placeholder="Search" SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"/>
                            <StackLayout VerticalOptions="FillAndExpand">
                                <StackLayout VerticalOptions="FillAndExpand" Padding="1" BackgroundColor="Black">
                                    <ListView x:Name="dataList"  BackgroundColor="White">
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <ViewCell>
                                                    <Label FontSize="20" VerticalOptions="CenterAndExpand" TextColor="Black" Text="{Binding HeadLines}"></Label>
                                                </ViewCell>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>
                                </StackLayout>
                            </StackLayout>
                        </StackLayout>

回答

您的XAML结构是错误的。请看一下我的代码,然后再试一次。希望对你有帮助

代码

<Grid VerticalOptions="FillAndExpand">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <SearchBar Grid.Column="0" x:Name="searchBar" Placeholder="Search" SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}" />
    <ListView Grid.Column="2" x:Name="dataList" BackgroundColor="White">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Label FontSize="20" VerticalOptions="CenterAndExpand" TextColor="Black" Text="{Binding HeadLines}">
                    </Label>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Grid>


问题是帮助在列表视图中滚动。在您更正的xaml中,卷轴在哪里?您不应该将一个可滚动的东西放在另一个可滚动的东西中。为什么需要scrollview?同意,如果listview将自动滚动,则不需要scrollview。但是您可以通过明确指出Xaml的错误来改进答案