How to find that ScrollViewer is scrolled to the end in WPF?

后端 未结 2 530
醉话见心
醉话见心 2020-11-30 06:13

I have a ScrollViewer instance in my custom control... I need the requirement that whether scorollview is scrolled to the End? Is there any way?

2条回答
  •  余生分开走
    2020-11-30 07:14

    You can check this with this way:

    ...
    scrollViewer.ScrollChanged += OnScrollChanged;
    ...
    
    private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
    {
       var scrollViewer = (ScrollViewer)sender;
       if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)
              MessageBox.Show("This is the end"); 
    }
    

提交回复
热议问题