Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove the item which is selected in other ComboBox from source?
    primarykey
    data
    text
    <p>Suppose we have four ComboBoxes in view (<a href="https://gist.github.com/JerryBian/7804536" rel="nofollow">source</a>):</p> <pre><code>&lt;StackPanel&gt; &lt;ComboBox ItemsSource="{Binding SourceCollection1}" DisplayMemberPath="Name" SelectedItem="{Binding Selected1}"/&gt; &lt;ComboBox ItemsSource="{Binding SourceCollection2}" DisplayMemberPath="Name" SelectedItem="{Binding Selected2}"/&gt; &lt;ComboBox ItemsSource="{Binding SourceCollection3}" DisplayMemberPath="Name" SelectedItem="{Binding Selected3}"/&gt; &lt;ComboBox ItemsSource="{Binding SourceCollection4}" DisplayMemberPath="Name" SelectedItem="{Binding Selected4}"/&gt; &lt;/StackPanel&gt; </code></pre> <p>And the VM something like (<a href="https://gist.github.com/JerryBian/7804542" rel="nofollow">source</a>):</p> <pre><code>public ObservableCollection&lt;People&gt; SourceCollection1 { get; set; } ... private People _selected1; public People Selected1 { get { return _selected1; } set { var pc = PropertyChanged; if (pc != null) { _selected1 = value; pc(this, new PropertyChangedEventArgs("Selected1")); } } } ... </code></pre> <p>And the <code>People</code> class has two properties: <code>Name</code> and <code>Age</code>.</p> <p>So, I'd like to implement this feature: when user selected one item in <code>ComboBox1</code>, then the remaining ConboBoxes should adapt their own ItemsSource, removing the items which have been selected in other ComboBoxes.</p> <p>For example, the application start up, and no item has been selected yet. Then user select <code>people A</code> in <code>ComboBox1</code>, so when user opens <code>ComboBox2</code> dropdown list, the <code>people A</code> item shouldn't be include in the <code>ComboBox2</code> source. So when user select p<code>eople B</code> in <code>ComboBox2</code>, the <code>ComboBox3</code> shouldn't have <code>people A</code> and <code>people B</code>. And so on...</p> <p>Does anyone have some nice solutions? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload