Ejemplo n.º 1
0
        /// <summary>
        /// Called to inform the list box that one of its items was clicked.
        /// </summary>
        /// <param name="container">The item container that was clicked.</param>
        internal void HandleItemClicked(ListBoxItem container)
        {
            switch (SelectionMode)
            {
                case SelectionMode.Single:
                    HandleItemClickedSingle(container);
                    break;

                case SelectionMode.Multiple:
                    HandleItemClickedMultiple(container);
                    break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles clicking on an item when the list box is in single selection mode.
        /// </summary>
        /// <param name="item">The item that was clicked.</param>
        private void HandleItemClickedSingle(ListBoxItem item)
        {
            BeginChangeSelection();

            if (GetIsSelected(item))
            {
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    UnselectContainer(item);
                }
            }
            else
            {
                UnselectAllItems();
                SelectContainer(item);
            }

            EndChangeSelection();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Handles clicking on an item when the list box is in multiple selection mode.
 /// </summary>
 /// <param name="item">The item that was clicked.</param>
 private void HandleItemClickedMultiple(ListBoxItem item)
 {
     var selected = GetIsSelected(item);
     if (selected)
     {
         UnselectContainer(item);
     }
     else
     {
         SelectContainer(item);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Selects the specified item and scrolls it into view.
 /// </summary>
 private void HandleItemClickedAndScrollIntoView(ListBoxItem item, Boolean buffer = true)
 {
     HandleItemClicked(item);
     ItemsControlUtil.ScrollItemIntoView<ListBoxItem>(this, PART_ScrollViewer, item, buffer);
 }