Exemplo n.º 1
0
        /// <summary>
        /// Select an item from the list
        /// </summary>
        private void SelectItem(object param)
        {
            // Cast the parameter
            var newSelectedItemIndex = int.Parse(param.ToString());

            // If the same item got selected there is no more to do
            if (mCurrentlySelectedItemIndex == newSelectedItemIndex)
            {
                return;
            }

            SelectionChanges.Invoke();

            LastClickedItemIndex = newSelectedItemIndex;

            ItemSelected.Invoke(newSelectedItemIndex);

            if (!CanChangeSelection)
            {
                return;
            }

            // Unselect last item if there was any selected
            if (mCurrentlySelectedItemIndex != NothingSelected)
            {
                Items[mCurrentlySelectedItemIndex].IsSelected = false;
            }

            // Select the one that has been clicked
            Items[newSelectedItemIndex].IsSelected = true;

            // Save new selected item index
            mCurrentlySelectedItemIndex = newSelectedItemIndex;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Unchecks all selected items
 /// </summary>
 public void UnCheckAll()
 {
     if (mCurrentlySelectedItemIndex != NothingSelected)
     {
         Items[mCurrentlySelectedItemIndex].IsSelected = false;
         SelectionChanges.Invoke();
     }
     mCurrentlySelectedItemIndex = NothingSelected;
     CanChangeSelection          = true;
 }