I want to bind a MySQL database to my WPF GridView. B开发者_运维技巧ut this doesn't work. I would like to do this:
MySqlDataAdapter adapter = new MySqlDataAdapter(query, connection);
MySqlCommandBuilder builder = new MySqlCommandBuilder(adapter);
DataTable table = new DataTable();
adapter.Fill(table);
BindingSource source = new BindingSource();
source.DataSource = table;
areaDataGrid.DataContext = table;
But the gid is empty. Why?
You need to set the ItemsSource
property
Here is a great article that walks you through exactly how to DataBind with the WPF DataGrid: http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx
精彩评论