tags:

views:

498

answers:

1

I have a combo box which is populated on selection's from two other combo'. No problem I have this working. Problem is I only want to activate the Selected Item binding after this has happened.

Here is my combo

 <cuc:ComboBox Name="GopLenTypeCombo" Width="240" Height="24"
                      IsSynchronizedWithCurrentItem="True"
                      SelectedValue="{Binding Mode=TwoWay, Source={StaticResource ProfileDataProvider}, XPath=GopLenType}" 
                      IsEnabled="False"/>

How do I stop the SelectedValue binding working untill I have populated the combo ?

+1  A: 

I don't know whether this is possible in pure XAML, but if you have an underlying ViewModel, this wouldn't be too hard:

What you would need to do is to bind your third ComboBox to a property on the ViewModel (let's call this property Combo3Items).

You would also need to bind the two first ComboBoxes to properties on the same ViewModel (let's call these Combo1Items and Combo2Items, respectively). In addition to that, you could bind both of these ComboBoxes' SelectedValue to properties on the ViewModel, so that the ViewModel knows which items are selected.

Initially, Combo3Items would be empty, but as soon as the two bound SelectedValues are properly assigned, you can fill Combo3Items and raise an INotifyPropertyChanged event.

The MVVM architecture is very powerful. If you don't already know it, you can read more about it here.

Mark Seemann