I have a checkbox and a comboBox, both constructed at code behind as follows:
var el = new ComboBox();
var checkBox = new CheckBox { Name = "myCheckBox" };
el.SetBinding(UIEelement.IsEnabledProperty, new Binding("IsChecked") { ElementName = checkBox.Name });
They are both placed inside the same Grid.
The binding works fine if I place the Grid directly inside my UserControl. But, when I place the Grid inside a TabItem, then put the TabItem inside a TabControl at my UserControl, the binding doesn't work.
We were able to fix this by changin the binding as follows, but I really want to understand why the previous does not work.
el.SetBinding(UIEelement.IsEnabledProperty, new Binding("IsChecked") { Source = checkBox });
Is it a problem of scope, even if the checkbox and the combo are in the same one?