开发者

How to stop scrollViewer at that position and draw

In xaml, I have the following:

ScrollViewer Name="Scv" HorizontalAlignment="Left" Margin="150,194,0,0" VerticalAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"

Canvas Height="100"开发者_运维百科 Name="canvas1" Width="424"

Image Canvas.Left="7" Canvas.Top="10" Height="150" Name="image1" Stretch="Fill" Width="200" ManipulationStarted="image1_ManipulationStarted"

InkPresenter Name="inkPresenter1"

inkPresenter1>

Canvas

ScrollViewer

The problem :

How to stop the ScrollViwer at the position where I stop scrolling as I need to draw something on the photo at that position?

If I use a button to stop it, it always return to the Top position even I have scrolled at the bottom

when click button to stop

Scv.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;

Scv.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;

To resume scrolling after stop

Scv.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;

Scv.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;


Given that sc is the name of the ScrollViewer control, you can set the current scrolling offset to the actual one and it will stop scrolling. Like this:

sc.ScrollToVerticalOffset(sc.VerticalOffset);

If you decide to scroll it horizontally, the same idea applies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜