alexandrovdi
alexandrovdi

Reputation: 301

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.

Upvotes: 0

Views: 5001

Answers (2)

blindmeis
blindmeis

Reputation: 22445

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.

Upvotes: 1

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48568

For Datatable we do

mydatagrid.ItemSource = mydatatable.DefaultView

Upvotes: 2

Related Questions