双向上的ScrollViewer结合VerticalOffset房产吗? [英] Two-Way Binding Of VerticalOffset Property on ScrollViewer?

查看:125
本文介绍了双向上的ScrollViewer结合VerticalOffset房产吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个观点,并在Silverlight 3.0视图模型。

I have a View and a ViewModel in Silverlight 3.0.

该视图包含一个标准的ScrollViewer,其中包含动态内容。

The view contains a standard ScrollViewer, which contains dynamic content.

根据的ScrollViewer内的内容时,用户可能滚动一半时的内容,然后执行引起该ScrollViewer中装载新的内容的动作,但的ScrollViewer不会自动滚动到顶部。

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.

我希望能够绑定到VerticalOffset属性,但它是只读的。上附着行为的任何想法?
任何想法?

I want to be able to bind to the VerticalOffset property, but it is read-only. Any ideas on attachable behavior? Any ideas?

感谢。

推荐答案

的下面的博客文章提供了一个附加的行为,它公开的ScrollViewer的垂直/水平偏移,这样就可以绑定到他们,或将他们的代码:

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

这允许以下标记:

<ScrollViewer 
    local:ScrollViewerBinding.VerticalOffset="{Binding YPosition, Mode=TwoWay}"
    local:ScrollViewerBinding.HorizontalOffset="{Binding XPosition, Mode=TwoWay}">
    <!-- Big content goes here! -->
</ScrollViewer>

这篇关于双向上的ScrollViewer结合VerticalOffset房产吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆