/// <summary> /// Example of using the scroll-state changed event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void myList_ScrollingStateChanged(object sender, ScrollingStateChangedEventArgs e) { if (e.NewValue) textblock.Foreground = new SolidColorBrush(Colors.Red); else textblock.ClearValue(TextBlock.ForegroundProperty); }
/// <summary> /// Handler for when the IsScrolling dependency property changes /// </summary> /// <param name="source">The object that has the property</param> /// <param name="e">Args</param> static void IsScrollingPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { LazyListBox listbox = source as LazyListBox; // The property is supposed to be read-only, although we are allowed to change it ourselves if (listbox.allowChangesToIsScrolling != true) { listbox.IsScrolling = (bool)e.OldValue; throw new InvalidOperationException("IsScrolling property is read-only"); } if ((bool)e.NewValue == true) { // Ask all the items in the list to pause what they're doing foreach (LazyListBoxItem item in listbox.visibleItems) item.Pause(); } // Call the virtual notification method for anyone who derives from this class ScrollingStateChangedEventArgs scrollingArgs = new ScrollingStateChangedEventArgs((bool)e.OldValue, (bool)e.NewValue); listbox.OnScrollingStateChanged(scrollingArgs); // Raise the event, if anyone is listening to it var handler = listbox.ScrollingStateChanged; if (handler != null) handler(listbox, scrollingArgs); // If the list has stopped scrolling, recompute the visible items on the next tick if ((bool)e.NewValue == false) { #if ONLISTCHANGESCOMPLETE_LOGGING Debug.WriteLine("IsScrollingPropertyChanged calling DeferredOnListChangesComplete because scrolling just finished"); #endif listbox.DeferredOnListChangesComplete(); } }
/// <summary> /// Notification that the scrolling state has changed /// </summary> /// <param name="e">Scrolling parameters</param> /// <remarks> /// The default implementation does nothing /// </remarks> protected virtual void OnScrollingStateChanged(ScrollingStateChangedEventArgs e) { }