Использование прокрутки в просмотре списка xamarin.forms

Я возвращаю около 20 строк данных в моем списке просмотра, и он показывает только 12. Как я могу представить прокрутку в моем списке просмотра ниже. Я попытался поместить прокрутку вокруг этого, но безуспешно.

     <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>

1 ответ

Ответ

Ваша структура 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>
Другие вопросы по тегам