【问题标题】:Cannot scroll to bottom wpf无法滚动到底部wpf
【发布时间】:2014-03-27 13:43:25
【问题描述】:

我有一个包含对象的列表框,但我无法滚动到页面底部。问题是什么?这是我正在使用的代码。

           <Grid>
                <Image Name="Nietcomment" Source="write.png" Width="70" Margin="350,-850,0,0" Tap="Login_popup" Visibility="Visible"/>
                <Image Name="welcomment" Source="write2.png" Width="70" Margin="350,-850,0,0" Tap="Login_popup_remove" Visibility="Collapsed"/>
                <ScrollViewer Name="scrollview" VerticalScrollBarVisibility="Visible" Margin="0,0,0,0" Foreground="Black">
                    <StackPanel>
                        <TextBlock x:Name="NTitelComment" Text="{Binding}" TextWrapping="Wrap" FontSize="25" Margin="10,0,10,0" Foreground="#FFE5001b"/>
                        <Line Stretch="Fill" Stroke="Black" X1="0" X2="1" Y1="0" Y2="0" Margin="10,0,10,0"/>
                        <TextBlock x:Name="tijdComment" Text="{Binding}" Margin="50,0,10,0" Foreground="Black"/>
                        <Image Height="20" Width="20" Margin="-380,-20,0,0" Source="/PostDateIcon.png"/>
                        <ListBox Margin="0,0,0,20" Name="lbComments" VerticalAlignment="Top" />

                    </StackPanel>
                </ScrollViewer>
           </Grid>

【问题讨论】:

  • 首先,清理您的代码并删除所有边距,以及您的 ListBox 周围的 Stackpanel,这是不需要的。您有一个未使用的Grid.Row="1" 等。那么帮助和阅读您的代码会更容易,也适合您。

标签: c# xaml windows-phone-8 listbox scroll


【解决方案1】:

如果你在你的 ScrollViewer 周围加上一个边框,你能看到它是否超出了屏幕之外吗?设置 Grid 或 ScrollViewer 的固定高度会有所帮助吗? 请记住,手机内置了滚动功能,因此您的 ScrollViewer 可能无法很好地使用它。

【讨论】:

    【解决方案2】:

    有了这么多的固定边距,您的布局将无法管理,尤其是在处理不同的屏幕分辨率时,尤其是在负边距的情况下。 无论如何,现在,您有两个滚动查看器,因为您的列表框也包含一个。 您应该禁用列表框滚动查看器,否则它将阻止您的页面滚动。 只需更改您的列表框:

    <ListBox 
        Margin="0,0,0,20" 
        ScrollViewer.VerticalScrollBarVisibility="Disabled" 
        Name="lbComments" 
        VerticalAlignment="Top" />
    

    它将禁用它的滚动查看器并允许它与页面的其余部分一起滚动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多