ADO.NET Entity Framework 4.0 : DataBinding with Windows Presentation Foundation (WPF)

ADO.NET Entity Framework 4.0 : DataBinding with Windows Presentation Foundation (WPF)

  • Comments 1

This post is to give an idea on how easily we can bind and create master details display in WPF.

 

Here I am using Northwind sample database and using Category and Products tables. These two tables are connected with each other through CategoryId. We will create a model using these two tables. Please ensure that you check the Foreign Key checkbox while selecting table in the EF4 model creation wizard.

image

Now, add two controls ListBox with id listBox1 and DataGrid with dataGrid1. Set the AutoGeneratedColumns to checked for the DataGrid.

 

Now open the Show Data Source from Visual Studio from Data Source menu.

 

Drop Category to listBox1 and Product (under Category) to dataGrid1. That’s all. Not a single line of code is required.

 

 

Namoskar!!!

Attachment: WpfApplication1.zip
Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
  • Hi.  I am a newb.  I tried this from scratch and with code in the zip--- I changed the data source to point to where Northwind is located on my C:\ in App.config connection string.  In both cases, I opened the Data Source viewer and there were no Data Sources, just the message that I have no data sources and the link to click and "add a new Data Source."  What am I missing?

Page 1 of 1 (1 items)