tags:

views:

31

answers:

0

Hi Experts,

I have implemented a binding on a selected item of a combobox as

ComboBox1.ItemsSource = Masters;
Binding binding = new Binding("RecordID");
binding.Source = Masters;
binding.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus;
binding.ValidatesOnDataErrors = true;
binding.Mode = BindingMode.TwoWay;

ComboBox1.SetBinding(ComboBox.SelectedItemProperty, binding);

In the above code "Masters" is a list of Master class objects which contains "RecordId" as one of its property.

Now i am not able to select a value/item from this combobox. I tried the following methods.

ComboBox1.SelectedValue = objMaster.RecordID;
ComboBox1.SelectedItem = objMaster.RecordID;

The above selection methods worked fine when i use the following instead of the binding mechanism.

ComboBox1.ItemsSource = Masters;
ComboBox1.SelectedValuePath = "RecordID";

Please help! Thanks in advance!

Regards,

Samar