0
votes

I put StackPanel into ScrollViewr, When scrolling to last item it returns back to its old position.

<ScrollViewer Margin="0,0,0,20">
<StackPanel>
  //Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>

After search i found that: ItemsControl, VirtualizingStackPanel and ScrollViewer height

I changed my code to:

<StackPanel>
  //Textblocks and Textboxes ...
</StackPanel>
<ScrollViewer>
<VirtualizingStackPanel />
 </ScrollViewer>

I can't set CanContentScroll="True" as i can't find it. Also make exception: System.InvalidOperationException: A VirtualizingPanel is not nested in an ItemsControl. VirtualizingPanel must be nested in ItemsControl to get and show items.

What must i do, to enable scrolling without returning back to its old position?

Regards,

1
Did you get bounce back effect in the first attempt? Like you couldn't really scroll, it was merely stretched?Toni Petrina
No, it scroll vertically but once i reach last item and remove my finger it return back to the top again.Samar ElFwakhry
Can you scroll to the half of the list without auto scroll to the top?Toni Petrina
Exactly I have 4 textboxes, I enter data at 1st one, I want to scroll to the last to write in it but, it scroll to just 2nd one and can't reach the last.Samar ElFwakhry
Can you post the full snippet with the surrounding code for the scroll viewer? Not the inside, but the outside XAML.Toni Petrina

1 Answers

0
votes

After search again ... I found this Post which solve the problem of Scrolling return to old position when open keyboard.

Scrolling page with keyboard shown

code after updates:

<ScrollViewer Height="500" VerticalAlignment="Top">
<StackPanel Height="700">
  //Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>