ScrollViewer滚动事件

时间:2013-01-31 07:30:25

标签: c# silverlight-4.0 silverlight-5.0

有没有办法捕获ScrollViewer的以下事件

ScrollViewer.ScrollStarter="ScrollStarted"
ScrollViewer.ScrollCompleted="ScrollCompleted"

2 个答案:

答案 0 :(得分:1)

我认为Silverlight中没有ScrollStartedScrollEnded等事件。但是,您可以创建Dependency Property收听水平和垂直Offset并使用此Dependecy Property来触发自定义事件,指示用户是否滚动。

This link包含一个示例;

答案 1 :(得分:1)

我认为你应该尝试我的方式

public static class ScrollViewerBinding
{
  #region VerticalOffset attached property

  /// <summary>
  /// Gets the vertical offset value
  /// </summary>
  public static double GetVerticalOffset(DependencyObject depObj)
  {
    return (double)depObj.GetValue(VerticalOffsetProperty);
  }

  /// <summary>
  /// Sets the vertical offset value
  /// </summary>
  public static void SetVerticalOffset(DependencyObject depObj, double value)
  {
    depObj.SetValue(VerticalOffsetProperty, value);
  }

  /// <summary>
  /// VerticalOffset attached property
  /// </summary>
  public static readonly DependencyProperty VerticalOffsetProperty =
      DependencyProperty.RegisterAttached("VerticalOffset", typeof(double),
      typeof(ScrollViewerBinding), 
    new PropertyMetadata(0.0, OnVerticalOffsetPropertyChanged));

  #endregion
}