简体   繁体   中英

ScrollViewer Scrolling Event

is there any way to catch the following Events for ScrollViewer

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

I think there are no events like ScrollStarted or ScrollEnded in silverlight. But you may create a Dependency Property listening the Horizontal and Vertical Offset s and use this Dependecy Property to fire a custom event indicating whether whether user scrolls or not.

This link includes a sample;

I Think You Should Try My Way

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
}

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