Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a datatable into wpf data grid

Tags:

wpf

datagrid

I'm trying to display the content of a datatable in my wpf datagrid

In the following post:

Why can't I bind the WPFToolkit DataGrid ItemSource to DataTable?

I found the code:

myDataGrid.ItemsSource = myDataTable.DefaultView;

and the behaviour is strange: it shows n empty rows where the n is correct: the query results n rows!

So why can't I see them?

like image 968
Asaf Avatar asked Nov 14 '22 06:11

Asaf


1 Answers

Without seeing the code, I would guess that you don't have AutoGenerateColumns set to to true. That's fine, but if you aren't auto-generating columns, you need to manually add column definitions to your data grid.

like image 52
Adam Barney Avatar answered Dec 10 '22 15:12

Adam Barney