Beispiel #1
0
 private void okButton_Click(object sender, RoutedEventArgs e)
 {
     for (int i = SourceCollection.Count - 1; i >= 0; i--)
     {
         object o = SourceCollection[i];
         if (!SourceCollectionEdited.Contains(o))
         {
             SourceCollection.RemoveAt(i);
         }
     }
     foreach (object o in SourceCollectionEdited)
     {
         if (!SourceCollection.Contains(o))
         {
             SourceCollection.Add(o);
         }
     }
     for (int i = TargetCollection.Count - 1; i >= 0; i--)
     {
         object o = TargetCollection[i];
         if (!TargetCollectionEdited.Contains(o))
         {
             TargetCollection.RemoveAt(i);
         }
     }
     foreach (object o in TargetCollectionEdited)
     {
         if (!TargetCollection.Contains(o))
         {
             TargetCollection.Add(o);
         }
     }
     cancelButton_Click(sender, e);
 }
Beispiel #2
0
        private void UpdateCheckBoxes()
        {
            if (!_isLoaded || _cleaningExtraItems || TargetCollection == null)
            {
                return;
            }
            try
            {
                _cleaningExtraItems = true;

                foreach (object obj in this.sourceListBox.Items)
                {
                    ListBoxItem container = this.sourceListBox.ItemContainerGenerator.ContainerFromItem(obj) as ListBoxItem;
                    if (container != null)
                    {
                        IList <DependencyObject> list = new List <DependencyObject>();
                        VTreeHelper.GetChildrenOfType(container, typeof(CheckBox), ref list);
                        if (list.Count > 0)
                        {
                            ((CheckBox)list[0]).IsChecked = TargetCollectionEdited.Contains(obj);
                        }
                    }
                }
            }
            finally
            {
                _cleaningExtraItems = false;
            }
        }
Beispiel #3
0
 private void AddItemToTargetCollection(object item)
 {
     if (item != null)
     {
         if (!AllowMultipleSelection)
         {
             TargetCollectionEdited.Clear();
         }
         if (!TargetCollectionEdited.Contains(item))
         {
             TargetCollectionEdited.Add(item);
         }
     }
 }