예제 #1
0
        private static void OnItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            JumpListBox jumpListBox = sender as JumpListBox;

            if (jumpListBox == null)
            {
                throw new ArgumentException("The sender must be a JumpListBox");
            }

            IEnumerable items = e.NewValue as IEnumerable;

            var collection = new AlphabetizedCollection(jumpListBox.IndexedMember, jumpListBox.ImageMember);

            collection.AddRange(items);

            _orderedCollection = collection.OrderBy(c => c.FirstLetter).ToList();

            jumpListBox.mainListBox.DataContext       = null;
            jumpListBox._jumpListSelector.ItemsSource = collection;

            if (jumpListBox.IsPumped)
            {
                PumpList <AlphabetizedItemContainer> pumpList =
                    new PumpList <AlphabetizedItemContainer>(_orderedCollection);
                jumpListBox.mainListBox.ItemsSource = pumpList.Items;

                pumpList.StartPump();
            }
            else
            {
                jumpListBox.mainListBox.ItemsSource = _orderedCollection;
            }
        }
예제 #2
0
        private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            JumpListBox jumpListBox = sender as JumpListBox;

            if (jumpListBox == null)
            {
                throw new ArgumentException("The sender must be a JumpListBox");
            }

            if (e.NewValue == null)
            {
                jumpListBox.mainListBox.SelectedItem = null;
            }
        }
예제 #3
0
        private static void OnItemTemplateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            JumpListBox jumpListBox = sender as JumpListBox;

            if (jumpListBox == null)
            {
                throw new ArgumentException("The sender must be a JumpListBox");
            }
            DataTemplate template = e.NewValue as DataTemplate;

            if (template == null)
            {
                throw new ArgumentException("The template must be a DataTemplate");
            }

            jumpListBox.mainListBox.ItemTemplate = template;
        }