Beispiel #1
0
        private static void ScrollToNewItem_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            var ItemsControl = o as ItemsControl;

            if (ItemsControl == null)
            {
                throw new ArgumentException("Type mismatch", "o");
            }

            var Value          = (bool)e.NewValue;
            var StatusListener = GetScrollToNewItemWeakEventListener(ItemsControl);

            if (Value)
            {
                if (StatusListener == null)
                {
                    StatusListener = new ScrollToNewItemEventListener();
                }

                SetScrollToNewItemWeakEventListener(ItemsControl, StatusListener);
                ItemContainerGeneratorStatusChangedEventManager.AddListener(ItemsControl, StatusListener);
            }
            else
            {
                if (StatusListener != null)
                {
                    SetScrollToNewItemWeakEventListener(ItemsControl, null);
                    ItemContainerGeneratorStatusChangedEventManager.RemoveListener(ItemsControl, StatusListener);
                }
            }
        }
        private static void ScrollToNewItem_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            var ItemsControl = o as ItemsControl;
            if (ItemsControl == null)
                throw new ArgumentException("Type mismatch", "o");

            var Value = (bool)e.NewValue;
            var StatusListener = GetScrollToNewItemWeakEventListener(ItemsControl);
            if (Value)
            {
                if (StatusListener == null)
                    StatusListener = new ScrollToNewItemEventListener();

                SetScrollToNewItemWeakEventListener(ItemsControl, StatusListener);
                ItemContainerGeneratorStatusChangedEventManager.AddListener(ItemsControl, StatusListener);
            }
            else
            {
                if (StatusListener != null)
                {
                    SetScrollToNewItemWeakEventListener(ItemsControl, null);
                    ItemContainerGeneratorStatusChangedEventManager.RemoveListener(ItemsControl, StatusListener);
                }
            }
        }