0

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,

Community
  • 1
  • 1
Samar ElFwakhry
  • 59
  • 1
  • 1
  • 9

1 Answers1

0

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>
Community
  • 1
  • 1
Samar ElFwakhry
  • 59
  • 1
  • 1
  • 9