简体   繁体   中英

WPF Scrollviewer MouseUp

I have a control that has a ScrollViewer and in the ScrollViewer there is an Image control, what I would like to do is when my ScrollViewer reaches the bottom (see code) I would like to switch to the next Image .

    private void ImageScrollViewer_ScrollChanged(object sender, System.Windows.Controls.ScrollChangedEventArgs e)
{
  var scrollViewer = (ScrollViewer)sender;
  if (!_hasChangedDueToScroll)
  {
    if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight && scrollViewer.ScrollableHeight != 0.0)
    {
      if (_pageNo != _maxPageNo - 1)
      {
        ChangePage(_pageNo + 1);
        _hasChangedDueToScroll = true;
        scrollViewer.ScrollToTop();
      }
    }
  }
}

Thing is, the _hasChangedDueToScroll needs to be there so that the code does not just run through all images to the last one, so I want to change _hasChangedDueToScroll when the mouse button is up from the ScrollViewer , but even if i add an event for MouseUp , the event never executes.

Any ideas why that might be?

Thank you

使用PreviewMouseLeftButtonUp而不是MouseUp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM