SL 4: Monitor properties of ScrollViewer?

ぐ巨炮叔叔 提交于 2019-12-11 07:51:38

问题


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.

来源:https://stackoverflow.com/questions/6740136/sl-4-monitor-properties-of-scrollviewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!