0

I have an inkpresenter inside a scrollviewer for a Windows Phone 7 application. Often when the user starts to draw, the scrollviewer takes over mid stroke, making it hard to actually draw stuff. I tried disabling the ScrollBarVisibility when the inkpresenter needs to be used, but then the scroll viewer automatically pans back up to the top. So how can I prevent the scrollviewer from scrolling when the inkpresenter is in use, while still maintaining the scroll position?

<ScrollViewer Name="ScrollBars" VerticalScrollBarVisibility="{Binding ScrollEnabled}" >
    <Canvas Height="2000">
        ...
        <InkPresenter Name="InkCanvas" Strokes="{Binding Strokes}" Canvas.Top="500" />
    </ Canvas >
</ScrollViewer >

Edit:

So I tried using the scrolling function in the codebehind to update the vertical offset, where I have a button linked to the following code:

var offset = scrollViewer.VerticalOffset;
ScrollEnabled = ScrollBarVisibility.Disabled;
scrollViewer.ScrollToVerticalOffset(offset);

Again, it just goes back up to the top. Any idea whats wrong?

leesei
  • 6,020
  • 2
  • 29
  • 51
tbischel
  • 6,337
  • 11
  • 51
  • 73
  • Have you verified that the value of the `offset` variable is not zero? – Praetorian Apr 21 '11 at 20:19
  • I check the offset in the debugger, it was a nonzero number. Can "ScrollToVerticalOffset" be called when the scrollvarvisibility is disabled? – tbischel Apr 21 '11 at 20:42
  • I thought it could be, but maybe I am wrong about that. Sorry my answer didn't work. – Praetorian Apr 21 '11 at 20:47
  • Could you try calling `Scrollviewer.UpdateLayout` after calling `Scrollviewer.ScrollToVerticalOffset`? – Praetorian Apr 21 '11 at 21:00
  • yeah I had tried that route as well... doesn't appear to be working. Is there maybe an event to handle in the inkpresenter that I can handle the touch so it doesn't bubble up to the scrollviewer? – tbischel Apr 21 '11 at 21:30

1 Answers1

1

After disabling the VerticalScrollBarVisibility call Scrollviewer.ScrollToVerticalOffset to manually bring the InkPresenter into view.

Praetorian
  • 106,671
  • 19
  • 240
  • 328