/// <summary>
        /// add selected available items to Current Items list.
        /// </summary>
        void RightArrow_Click(object sender, RoutedEventArgs e)
        {
            if (this.DataContext is IMultiSelectControlCommands)
            {
                var externalCommands = (IMultiSelectControlCommands)this.DataContext;
                if (AvailabeListBox.SelectedItems.Count > 0)
                {
                    externalCommands.SelectItem(AvailabeListBox.SelectedItems[0]);
                }
            }
            else
            {
                //A copy is used, because the collection is changed in the iteration
                IList selectedItems =
                    new List <object>((IEnumerable <object>)AvailabeListBox.SelectedItems);
                IList currentListItems = CurrentItems as IList;
                if (null != currentListItems)
                {
                    foreach (object obj in selectedItems)
                    {
                        currentListItems.Add(obj);
                    }
                }
            }

            //updates the available collection
            AvailableItemsCollectionView.Refresh();
        }
        private void SetupCurrentItems()
        {
            var currentCollectionView = CollectionViewSource.GetDefaultView(CurrentItems);

            UpDownButtonsVisible = currentCollectionView.SortDescriptions.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
            if (AvailableItemsCollectionView != null)
            {
                AvailableItemsCollectionView.Refresh();
            }
        }
 /// <summary>
 /// setup Available Items list to filter by Current Items list.
 /// </summary>
 private void SetupAvailableItems()
 {
     AvailableItemsCollectionView = CollectionViewSource.GetDefaultView(AvailableItems);
     if (AvailableItemsCollectionView.Filter == null)
     {
         AvailableItemsCollectionView.Filter = new Predicate <object>(FilterOutCurrentItems);
     }
     else
     {
         AvailableItemsCollectionView.Refresh();
     }
 }
        /// <summary>
        /// Remove all items from current list.
        /// </summary>
        void DoubleLeftArrow_Click(object sender, RoutedEventArgs e)
        {
            IList currentListItems = CurrentItems as IList;

            if (this.DataContext is IMultiSelectControlCommands)
            {
                var externalCommands = (IMultiSelectControlCommands)this.DataContext;
                externalCommands.UnSelectAllItems(currentListItems);
            }
            else
            {
                if (null != currentListItems)
                {
                    currentListItems.Clear();
                }
            }

            //updates the available collection
            AvailableItemsCollectionView.Refresh();
        }
        /// <summary>
        /// Add all Available Items to Current Items list.
        /// </summary>
        void DoubleRightArrow_Click(object sender, RoutedEventArgs e)
        {
            if (this.DataContext is IMultiSelectControlCommands)
            {
                var externalCommands = (IMultiSelectControlCommands)this.DataContext;
                externalCommands.SelectAllItems(AvailableItemsCollectionView);
            }
            else
            {
                IList currentListItems = CurrentItems as IList;
                if (null != currentListItems)
                {
                    foreach (object obj in AvailableItemsCollectionView)
                    {
                        currentListItems.Add(obj);
                    }
                }
            }

            AvailableItemsCollectionView.Refresh();
        }