Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have set up a Grid inside a ScrollViewer. At runtime, based on the results of a search I dynamically build a number of checkboxes which I add as Children to the Grid. This all works fine.

But, when I select a CheckBox, the ScrollViewer moves and places the checked box to the top of the view.

For instance, if the box I want to check is in the middle of the view, when I check it, it moves to the top of the view while its place in the overall list remains the same.

What I have tried:

<ScrollViewer Grid.Row="0" Margin="5,5,5,5" VerticalScrollBarVisibility="Visible" BorderBrush="Black" BorderThickness="1" >
           <Grid x:Name="InnerGrid1" >
           </Grid>
       </ScrollViewer>
Posted
Comments
[no name] 25-Jan-21 11:27am    
What does "select" mean? You can "scroll" (or select) any number of ways.

https://docs.microsoft.com/en-us/dotnet/desktop/wpf/controls/how-to-use-the-content-scrolling-methods-of-scrollviewer?view=netframeworkdesktop-4.8
AwileyDog 25-Jan-21 14:01pm    
When I check a CheckBox, the scrollbar moves down so that the item that I checked moves to the top of the window. I do not want the scrollbar to move at all when an item is checked.
#realJSOP 21-Feb-21 6:30am    
Are you adding Grid.RowDefinitions to your grid for each checkbox? I created a simple window with a grid in a scrollviewer, and cannot duplicate the behavior you describe. I didn't dynamically add the checkboxes, but when I click a checkbox, the scrollviewer does not scroll it to the top.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900