Patrick Jore
Patrick Jore

Reputation: 43

Cannot scroll to bottom wpf

I have a listbox with objects but I cannot scroll to the bottom of the page. What is the problem? This is the code that I'm using.

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

Upvotes: 2

Views: 1135

Answers (2)

MakanWG
MakanWG

Reputation: 165

With so much fixed margins, your layout will be impossible to manage, especially when dealing with differents screen resolutions and especially with negative margins. Anyway, right now, you have two scrollviewers, as your listbox contains one as well. You should disable the listbox scrollviewer or it will prevent your page to scroll. Just change your listbox:

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

It will disable it's scrollviewer and allow it to scroll with the rest of the page.

Upvotes: 0

cederlof
cederlof

Reputation: 7383

If you put a border around your ScrollViewer, can you see if it goes outside of the screen maybe? Will it help to set a fixed height of the Grid or ScrollViewer? Keep in mind the phone has built in scroll, so your ScrollViewer maybe doesn't play well with it.

Upvotes: 1

Related Questions