Friday, October 22, 2010

Windows Phone: Preventing the panorama control from scrolling

I have a panorama control that contains an InkPresenter control. Needless to say while drawing in the InkPresenter, the panorama manipulation events would still fire, scrolling the panorama.

I tried to google on how to temporarily lock the scrolling, and couldn’t find anything, hence this post.

The solution turned out to be quite simple: Subscribe to the ManipulationStarted event of the panorama control. You can then call the Complete() method on the event args to stop the manipulation.

So in my specific example, when the MouseLeftButtonDown event occured on the InkPresenter, I’d just set a local boolean “_panoScrollLocked” to true. This can then be queried on the Manipulation event of the panorama to prevent scrolling. Reset the variable again on the MouseLeftButtonUp event of the InkPresenter to restore the scrolling behaviour.

The same technique can be used for the Pivot control

Happy Coding :)

No comments: