You need to associate a DataGrid with a sheet or database table. This is how I associate a grid with a sheet.

public List<CopiesOut> _bookList = new List<CopiesOut>(); public List<CopiesOut> BookList { get { return _bookList; } set { _bookList = value; OnPropertyChange("BookList"); } } ItemsSource="{ Binding Path=BookList, Mode=OneWayToSource, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, BindsDirectlyToSource=True, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged }" 

But when the BookList is changed by the button, the grid does not change. I tried to change the sheet in the constructor, absolutely nothing is displayed on the grid.

In this regard, tell me how to correctly bind all the sheets to the data grid there, leave good articles, tutorials. Thank you in advance for your help.

  • Can you have a DataContext empty? - Murad
  • Not empty. ViewModel VM = new ViewModel (); DataContext = VM; - Yaroslav Schubert

1 answer 1

If I understood the problem correctly, then ...

With Mode=OneWayToSource there will be no changes on the screen when the Source changes.

You need OneWay or TwoWay .

BindingMode Enumeration .

  • Tried to change - did not help. That earned changed list on ObservableCollection - Yaroslav Schubert
  • Maybe. I use the custom class inherited from BindingList <T> in my wpf projects, so used that I don’t even look at it ... - k0balt