Hi all,
I am working on a WPF C# app where I have two comboboxes and two listboxes. On load I populate both comboboxes with the same data. What I want to do on selection changed event of the first combobox is to compare the selected text with all the items in the 2nd combobox and when it is found it should be removed from the 2nd combobox because I am trying to avoid selecting the same record on both comboboxes. (The data in the comboboxes comes from the database).
This is the logic of what I want to do:
The comboboxes are loaded with teacher's names. So when I select a teacher on the 1st one, I then choose students on the 1st listbox and move them to the 2nd one where I also select a teacher on the 2nd combobox then I save the teacher in the 2nd combobox with the students in the 2nd listbox because I am exchanging students between these two teachers, that is why I dont want teacher "a" to be re-assigned to the same students because then there will have been no exchange done.

Nattudurai EswaramurthyRank #5,536 · 296 reputationPosted Aug 20, 2012, 1:20 AM EDT
i thought about it and i would probably approach it with a MultiBinding and a respective ValueConverter, i.e.
public class ComboBoxItemsSourceFilter : IMultiValueConverter { #region IMultiValueConverter Members public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var collection = new List((object[])values[0]); foreach (var item in values.Skip(1)) { if (item != null) collection.Remove(item); } return collection; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotSupportedException(); } #endregion }