简体   繁体   English

WPF Scrollviewer鼠标向上

[英]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 . 我有一个具有ScrollViewer的控件,并且在ScrollViewer有一个Image控件,我想做的是当ScrollViewer到达底部时(请参见代码),我想切换到下一个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. _hasChangedDueToScroll是, _hasChangedDueToScroll必须在该_hasChangedDueToScroll中,以便代码不只是遍历所有图像到最后一张,所以我想在ScrollViewer的鼠标按钮向上时更改_hasChangedDueToScroll ,即使我为MouseUp添加了一个事件,事件将永远不会执行。

Any ideas why that might be? 任何想法为什么会这样?

Thank you 谢谢

使用PreviewMouseLeftButtonUp而不是MouseUp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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