I have a View and a ViewModel in Silverlight 3.0.
The view contains a standard ScrollViewer, which contains dynamic content.
Depending on the content within the ScrollViewer, the user could have scrolled half way down the content, and then performed an action that causes the ScrollViewer to load new content, but the ScrollViewer does not automatically scroll to the top.
I want to be able to bind to the VerticalOffset property, but it is read-only. Any ideas on attachable behavior? Any ideas?
Thanks.
The following blog post provides an attached behaviour that exposes the vertical / horizontal offsets of a scrollviewer so that you can bind to them, or set them in code:
http://blog.scottlogic.com/2010/07/21/exposing-and-binding-to-a-silverlight-scrollviewers-scrollbars.html
This allows the following markup:
<ScrollViewer
local:ScrollViewerBinding.VerticalOffset="{Binding YPosition, Mode=TwoWay}"
local:ScrollViewerBinding.HorizontalOffset="{Binding XPosition, Mode=TwoWay}">
<!-- Big content goes here! -->
</ScrollViewer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With