0
votes

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?

1
Have you verified that the value of the offset variable is not zero? - Praetorian
I check the offset in the debugger, it was a nonzero number. Can "ScrollToVerticalOffset" be called when the scrollvarvisibility is disabled? - tbischel
I thought it could be, but maybe I am wrong about that. Sorry my answer didn't work. - Praetorian
Could you try calling Scrollviewer.UpdateLayout after calling Scrollviewer.ScrollToVerticalOffset? - Praetorian
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

1 Answers

1
votes

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