SL 4:监视 ScrollViewer 的属性?
我们有一个包含在 ScrollViewer 中的 Canvas。用户可以添加无限数量的 UserControl,简单来说,这些 UserControl 是一个被许多装饰性矩形包围的 RichTextControl。
我们有一个安排器来定位所有用户控件,因此不会重叠。当排列器运行时,它会计算每个 UserControl 的新位置,并在画布上设置其 X 和 Y。
然而,某些因素导致 ScrollViewer 滚动,因此在排列程序运行后,用户可能会看到其所有项目的不同视图。
我寻找了一个事件来挂钩,看看是什么可能导致 SV 发生变化,但看起来没有合适的事件。 (ManipulationStarted 仅在 WP7 上可用。)
是否有一个我们可以绑定的属性,以尝试找出 SV 的水平和垂直偏移量发生变化的原因?
感谢您对可能发生的情况有任何见解。
更新:我在一个更简单的项目中重现了这个。当 RichTextBox 的内容发生更改时,就会发生恶作剧 - RTB 被引入查看。
有什么办法可以防止这种情况发生吗?也许是 ScrollViewer 上的某些属性?
TIA...
更新 2:看来 RTB SizeChanged 事件会导致 ScrollViewer 将 RTB 引入视图。虽然我们可以为 SizeChanged 事件添加处理程序,但没有 OnSizeChanged 可重写方法。
We have a Canvas contained in a ScrollViewer. Users can add an unlimited number of UserControls that, to oversimplify, are a RichTextControl surrounded by a number of decorative rectangles.
We have an arranger that positions all the UserControls so none overlap. When the arranger runs, it calculates a new position for each UserControl and sets its X and Y on the Canvas.
Something is causing the ScrollViewer to scroll, however, so that after the arranger runs the user might have a different view of all their items.
I looked for an event to hook to see what could be causing the SV to change, but it didn't look like there is an appropriate one. (ManipulationStarted is only available on WP7.)
Is there a property we can bind to, to try to figure out why the SV's horizontal and vertical offsets are changing?
Thanks for any insights into what might be going on.
UPDATE: I have reproduced this in a simpler project. The mischief occurs when the content of a RichTextBox is changed -- the RTB is brought in to view.
Is there any way to prevent this? Some property on the ScrollViewer, perhaps?
TIA...
UPDATE 2: It appears the RTB SizeChanged event causes the ScrollViewer to bring the RTB into view. While we can add a handler for the SizeChanged event, there is no OnSizeChanged overrideable method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论