Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 2
0
 /// <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)
 {
 }