C# 无法滚动到底部wpf

C# 无法滚动到底部wpf,c#,xaml,windows-phone-8,listbox,scroll,C#,Xaml,Windows Phone 8,Listbox,Scroll,我有一个包含对象的列表框,但无法滚动到页面底部。有什么问题?这是我正在使用的代码 <Grid> <Image Name="Nietcomment" Source="write.png" Width="70" Margin="350,-850,0,0" Tap="Login_popup" Visibility="Visible"/> <Image Name="welcomment"

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

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

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

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

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


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

首先,清理代码并删除列表框周围不需要的所有边距和Stackpanel。您有一个未使用的
网格。Row=“1”
等。这样,您也可以更轻松地帮助和阅读您的代码。