I have datagrid and combobox in form. The combobox is attached to the selected datagrid element.
I load everything in order, and if I select different lines, then combobox is updated accordingly.
If, however, I set datagrid.selectedIndex = -1 after loading (so the first row is not selected), the combobox binding no longer works. This is problem.
I also have another scenario where the exact thing happens. If I filter the datagrid, combobox binding also stops working.
I bind a datagrid to a CollectionViewSource as shown below, where _codes is an ObservableCollection
_ocvsCode = (CollectionViewSource) this.Resources ["cvsCode"]; _ocvsCode.Source = _codes; dataGrid1.ItemsSource = _ocvsCode.View;
Code>
I don't know why binding to combobox fails after some operation on a datagrid.
source
share