1

I have read most everything I can find to stop autoscrolling in a ScrollViewer without success.

The scenario is the following. I populate a scrollviewer with text hosted by a formatted text object. This is displayed as:

Scrollviewer showing formatted text object before word selection

I now scroll down and Tap/click on a word (e.g, "pearly"). The code now dynamically adds new controls on top of the selected word as shown:

enter image description here

All is good. However, when I now select the newly added control (e.g., "p"), the scrollviewer moves the control to the top of the view as shown:

enter image description here

The scrollviewer is defined in xaml as:

<Canvas Grid.Row="1" Grid.RowSpan="3" Grid.Column="0">
        <ScrollViewer VerticalScrollBarVisibility="Auto" 
        Width="{Binding Parent.ActualWidth, Mode=OneWay, RelativeSource={RelativeSource Self}}"
        Height="{Binding Parent.ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" >
                    <Grid Background="White" >

      ..............
     </Grid>
   </ScrollViewer>
</Canvas>

This is visually very distressing.

Any help at stopping this behavior is most appreciated. (Setting CanContentScroll to false does nothing :( ).

Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
  • 1
    Pretty sure you're looking for [RequestBringIntoView](https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.requestbringintoview%28v=vs.110%29.aspx) and if I remember right you can literally just slap like a null on that event at your control level and call it fixed. – Chris W. Jan 22 '15 at 00:26
  • @ChrisW That's it. Thanks. I found a workable solution at http://stackoverflow.com/questions/2064848/wpf-datagrid-how-do-i-stop-auto-scrolling-when-a-cell-is-clicked. – Alan Wayne Jan 22 '15 at 02:30

0 Answers0