加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows Phone 7 – WP7列表框滚动不工作

发布时间:2020-12-13 20:27:18 所属栏目:Windows 来源:网络整理
导读:我在WP7 UserControl中有以下XAML标记.我的问题是,当我的ListBox有更多的项目比适合在一个页面,它将不会滚动正确.我可以用手指向上滚动列表,但是一旦我删除我的手指,它就会跳回到列表的顶部(如果列表很长,那么滚动甚至不会在这个有限的范围内工作). 我尝试了
我在WP7 UserControl中有以下XAML标记.我的问题是,当我的ListBox有更多的项目比适合在一个页面,它将不会滚动正确.我可以用手指向上滚动列表,但是一旦我删除我的手指,它就会跳回到列表的顶部(如果列表很长,那么滚动甚至不会在这个有限的范围内工作).

我尝试了许多不同的布局,没有成功,例如在ScrollViewer中包装ListBox,使用StackPanel而不是Grid,删除WrapPanel并将其替换为网格.

其他类似的问题建议删除StackPanel(我做但没有任何区别)或使用ScrollViewer(这不工作).

托管UserControl的页面使用GestureListener – 我删除了它,它仍然没有区别.

<Grid x:Name="LayoutRoot"
      Background="SteelBlue">

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

    <!--<TextBlock Grid.Row="0"
               Text="Search"
               Style="{StaticResource PhoneTextTitle2Style}" />-->

    <Grid Grid.Row="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="Search Type"
                   Grid.Column="0"
                   VerticalAlignment="Center" />

        <RadioButton Content="RMB/RSD"
                     Grid.Column="1"
                     IsChecked="{Binding Path=SearchType,Converter={StaticResource enumBooleanConverter},ConverterParameter=RMB,Mode=TwoWay}" />

        <RadioButton Content="Name"
                     Grid.Column="2"
                     IsChecked="{Binding Path=SearchType,ConverterParameter=Name,Mode=TwoWay}" />
    </Grid>

    <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="Search Term"
                   Grid.Column="0"
                   VerticalAlignment="Center" />

        <TextBox Grid.Column="1"
                 Text="{Binding SearchTerm,Mode=TwoWay}"
                 InputScope="{Binding SearchTermInputScope}">
            <i:Interaction.Behaviors>
                <b:SelectAllOnFocusBehavior />
            </i:Interaction.Behaviors>
        </TextBox>

    </Grid>

    <Button Grid.Row="2"
            Content="Find"
            cmd:ButtonBaseExtensions.Command="{Binding FindDeliveryPointsCommand}" />

    <ListBox Grid.Row="3"
             ItemsSource="{Binding SearchResults}"
             ScrollViewer.VerticalScrollBarVisibility="Auto">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <toolkit:WrapPanel Orientation="Horizontal"
                                   Width="480"
                                   Background="{Binding RMB,Converter={StaticResource alternateColorConverter}}">
                    <TextBlock Text="{Binding RMB}"
                               FontSize="26"
                               Foreground="Navy"
                               Padding="5"
                               Width="60" />
                    <TextBlock Text="{Binding HouseholdName}"
                               FontSize="26"
                               Foreground="Navy"
                               Padding="5"
                               Width="420" />
                    <TextBlock Text="{Binding StreetWithRRN}"
                               FontSize="26"
                               Foreground="Navy"
                               Padding="5" />
                    <TextBlock Text="{Binding Street.Locality.Name}"
                               FontSize="26"
                               Foreground="Navy"
                               Padding="5" />
                </toolkit:WrapPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</Grid>
指定ListBox.Height – 像Height =“200”.如现在,ListBox自动扩展以容纳所有加载的项目,并且它会从屏幕中增长.因此,您可以获得没有滚动条的大页面.

当你添加ListBox.Height时,ListBox区域不会增长.相反,ListBox ScrollViewer将被激活,您将获得所需的效果.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读