在ListView UWP内部没有滚动

网站建设4年前发布
84 0 0

文章目录[隐藏]

在我的UWP应用中,我有一个 ListView 但这是固定的高度,不可滚动>我知道Stackoverflow上有许多类似的问题,但它们都没有帮助我。这是我的代码:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <TextBlock Text="{x:Bind Reply.heading}"
                   FontSize="20"
                   Grid.Row="0"
                   Margin="10"/>

        <ListView ItemsSource="{x:Bind Reply.faq, Mode=OneWay}"
                  SelectionMode="None"
                  IsHitTestVisible="False"
                  Grid.Row="1">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="models:FaqItem">
                    <Grid>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="*"></RowDefinition>
                        </Grid.RowDefinitions>


                        <TextBlock Text="{x:Bind question, Mode=OneWay}"
                                   FontWeight="SemiBold"
                                   TextWrapping="WrapWholeWords"
                                   FontSize="18"/>

                        <TextBlock Text="{x:Bind answer, Mode=OneWay}"
                                   Grid.Row="1"
                                   FontSize="16"
                                   TextWrapping="WrapWholeWords"
                                   Margin="0, 0, 0, 20"/>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>

看答案

滚动不起作用,因为您正在设置 IsHitTestVisible="False" 因此,删除该行,如果您想要具有自动高度的ListView,请设置 VerticalAllignment="Top" 如下所示:

....
 <ListView ItemsSource="{x:Bind Reply.faq, Mode=OneWay}"
                  SelectionMode="None"
                  VerticalAlignment="Top"
                  Grid.Row="1">
....
© 版权声明

相关文章

没有相关内容!