I have two properties of type ObservableCollection (in separate projects); What I want to do is bind the two using reflection and SetBinding, like this -
PropertyDescriptor relatedPropertyDesc = prop.Find(firstCollPropName, false);
Binding relatedPropBinding = new Binding(relatedPropertyDesc.Name);
relatedPropBinding.Source = this.SelectedItem;
relatedPropBinding.Mode = BindingMode.TwoWay;
propItem.SetBinding(MyItem.SecondCollProperty, relatedPropBinding);
This SecondCollProperty is then bound to the Items ComboBox element.
Thus, it works correctly, the values represented in firstCollProperty are displayed correctly in combobox; but , if some changes are made to firstCollProperty at run time, then they are not reflected in the ComboBox! (adding new items or creating a new collection object).
Changes are reflected correctly after updating the binding (execution of the above code again).
My question is - If two ObservableCollections are related to each other, why aren't any changes in the first reflected in the others? but the same thing works for string or double type properties.
Is there any way to achieve this?
source
share