Binding WPF combobox with changed collection
<p>I have a combobox inside a list where the items of the combo box are dynamic. They will be determined by the help of the selected item. </p>

<p>For example: If selected item is Item1 then combobox should contain Item1, Item2, Item3 but if selected item is Item2 then combo box should contain Item2, Item3, Item4</p>

<p>How to achieve the same by using binding..</p>

<p>Right now i am setting up two properties in my collection called SelectedValue and ListValues and binding them with my combobox but it only select first item of the list and leaving the rest one as it is.</p>

<p>
                                                        </p>

<p>Also, what is the order of execution of data binding as i want first Itemsource to call then selectedvalue should be set so that items will be selected.</p>

<p>Really appreciate for any help.</p>

<p>Here is my effort which works out but i am not sure if it's correct or not.</p>

<p>C#</p>

<pre><code>public string SelectedValue
{
    get
    {
        PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("Values"));
        return _value;
    }
    set
    {
        if (value != null) //It will be null when binding of values happens
        { 
            _value = value;
            PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("Values"));
            PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("SelectedValue"));
        }
    }
}

public IList&lt;SomeType&gt; Values
{
    get
    {
        string status =_status;
        return SomeFunctionToReturnValues(status);
    }
}
</code></pre>

<p>XAML</p>

<pre><code>&lt;ComboBox SelectedValue="{Binding SelectedValue}" SelectedValuePath="Id" DisplayMemberPath="Text" Width="120" ItemsSource="{Binding Values,Mode=OneWay}"&gt;&lt;/ComboBox&gt;
</code></pre>

<p>Please comment and Let me know if anyone can provide me better suggestion here.</p>