Hello
I want understand binding in WPF. In code I have an ObservableCollection called _orders.
I work with Entity Framework and classes have all needed properties.
I want to display orders in DataGrid. In dataGrid I have declared columns with Binding like this:
<DataGridTextColumn Header="OrderID" x:Name="OrdersTabOrderIDColumn" Binding="{Binding OrderID}" Visibility="Hidden"/>
and in code I do this:
OrdersDataGrid.ItemsSource = _orders;
Is it right ? Can I already put this _orders inside xaml code?
Next step is binding textbox, ComboBox to the OrdersDataGrid.SelectedItem.
When I click on some row inside DataGrid I want to display item properties in TextBoxes and ComboBoxes.
Right now I handle event DataGridSelectionChanged, in event I check if selectedItem isn't null, and if isn't I manually rewrite properties to textboxes and comboBox.SelectedVale. ComboBox is binded inside code:
productsComboBox.ItemsSource = _products
When I want to save my changed order I have to read values from textboxes, comboboxes and write to object and then save it in database.
How can I do this automatically with binding?