简体   繁体   中英

How load data in datagrid in WPF Application

In WinForms i do this:

var fromtable = from a in Table1 select a;
DataGridView.DataSource = fromtable;

And i see data. How make same in wpf application?

If i do like this:

Museum_TrueEntities me = new Museum_TrueEntities();
 var test = from a in me.Authors select a;
 dataGrid1.ItemsSource = test;

In result DataGrid is empty.

对于数据表,我们这样做

mydatagrid.ItemSource = mydatatable.DefaultView

dont forget to set AutogenerateColumns=true in your datagrid.

if you create the columns by your self post some xaml and set the correct binding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM