1

Topic: WPF, EF, DataGrid, ForeignKey

I welcome. There is a DB and there is such model: public class Cargo {//... public int CargoCodeId {get; set;} [ForeignKey ("CargoCodeId")] public CargoCode cargocode {get; set;}} public class CargoCode {[Key] public int Id {get; set;} public string Type {get; set;} public string Material {get; set;} public string TypeCh {get; set;} public string MaterialCh {get; set;} public IList <Cargo> Cargos {get; set;} } Here so it it is displayed in DataGrid: <DataGridComboBoxColumn Header = "the type Code" x:Name = "cmbtype" SelectedValueBinding = "{Binding Path=CargoCodeId}" DisplayMemberPath = "Id" SelectedValuePath = "Id"> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType = "{x:Type ComboBox}"> <EventSetter Event = "SelectionChanged" Handler = "CodeSelectionChanged"/> </Style> </DataGridComboBoxColumn.EditingElementStyle> </DataGridComboBoxColumn> <DataGridTextColumn MaxWidth = "75" Binding = "{Binding Path=cargocode. Type}" Header = "goods Type" IsReadOnly = "True"/> <DataGridTextColumn MaxWidth = "75" Binding = "{Binding Path=cargocode. TypeCh}" Header = "Type (Chinese)" IsReadOnly = "True"/> <DataGridTextColumn MaxWidth = "75" Binding = "{Binding Path=cargocode. Material}" Header = "Material" IsReadOnly = "True"/> <DataGridTextColumn MaxWidth = "75" Binding = "{Binding Path=cargocode. MaterialCh}" Header = "the Material (Chinese)" IsReadOnly = "True"/> i.e. The type identifier is deduced in the drop down list with choice possibility, and the data on an exterior key is deduced in adjacent cells. A question: how to make update of the data at value change in the drop down list? <EventSetter Event = "SelectionChanged" Handler = "CodeSelectionChanged"/> private void CodeSelectionChanged (object sender, SelectionChangedEventArgs e) {var comboBox = sender as ComboBox; BindData (); mainDG.Items. Refresh ();} does not allow to make Items. Refresh () since  at this time is in an editing mode