将滚动查看器锁定到位
我在 Windows Phone 7 应用程序的滚动查看器内有一个 inkpresenter。通常,当用户开始绘图时,滚动查看器会接管中间笔划,从而很难实际绘制内容。我尝试在需要使用 inkpresenter 时禁用 ScrollBarVisibility,但随后滚动查看器会自动平移回顶部。那么如何在使用 inkpresenter 时防止滚动查看器滚动,同时仍保持滚动位置呢?
<ScrollViewer Name="ScrollBars" VerticalScrollBarVisibility="{Binding ScrollEnabled}" >
<Canvas Height="2000">
...
<InkPresenter Name="InkCanvas" Strokes="{Binding Strokes}" Canvas.Top="500" />
</ Canvas >
</ScrollViewer >
编辑:
所以我尝试使用代码隐藏中的滚动功能来更新垂直偏移,其中我有一个链接到以下代码的按钮:
var offset = scrollViewer.VerticalOffset;
ScrollEnabled = ScrollBarVisibility.Disabled;
scrollViewer.ScrollToVerticalOffset(offset);
同样,它只是返回到顶部。知道出了什么问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
禁用
VerticalScrollBarVisibility
后,调用Scrollviewer.ScrollToVerticalOffset
手动将 InkPresenter 引入视图。After disabling the
VerticalScrollBarVisibility
callScrollviewer.ScrollToVerticalOffset
to manually bring the InkPresenter into view.