none
如何检测ScrollViewer控件的滚动条滚动到末尾? RRS feed

  • 问题

  • 我想让ScrollViewer自动循环滚动,但是不知道有有什么方法能检测出

    ScrollViewer的滚动条已经滚动到末尾.

    2011年5月30日 2:49

答案

  • 当  (scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight  的时候就能够确定竖向滚动条到了最低端;相应的横向也是一样:

     

          scrollviewer.ScrollChanged += (o, e) => {
            if ((scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight)
            {
              scrollviewer.ScrollToVerticalOffset(0);
            }
          };

    Sincerely,


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年5月30日 7:13
    版主

全部回复

  • 当  (scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight  的时候就能够确定竖向滚动条到了最低端;相应的横向也是一样:

     

          scrollviewer.ScrollChanged += (o, e) => {
            if ((scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight)
            {
              scrollviewer.ScrollToVerticalOffset(0);
            }
          };

    Sincerely,


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年5月30日 7:13
    版主
  • 您给的方法正是我需要的,万分感谢~
    2011年5月30日 9:53
  • 当  (scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight  的时候就能够确定竖向滚动条到了最低端;相应的横向也是一样:

     

          scrollviewer.ScrollChanged += (o, e) => {
            if ((scrollviewer.VerticalOffset + scrollviewer.ViewportHeight) == scrollviewer.ExtentHeight)
            {
              scrollviewer.ScrollToVerticalOffset(0);
            }
          };

    Sincerely,


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    版主,请问这个在metro有办法实现吗
    2012年4月25日 6:20