MVVM datagrid binding

前端 未结 5 1594
深忆病人
深忆病人 2020-12-10 16:33

I\'m using MVVM for my project and I\'m trying to bind a table from my database with a DataGrid. But when I run my application datagrid is empty.

MainWindow.

5条回答
  •  醉话见心
    2020-12-10 17:13

    You have an error in binding. Try this:

    
    

    Code-behind:

    private ObservableCollection _lecturers = new ObservableCollection();
    public ObservableCollection Lecturers
    {
       get { return _lecturers; }
       set { _lecturers = value; }
    }
    

    Here is simple example code (LecturerSimpleBinding.zip).

提交回复
热议问题