Tuesday, January 29, 2008

Databinding the Entity Framework to the Free Xceed WPF DataGrid

Julie Lerman Blog - Binding EF data to the (free) Xceed WPF Data Grid

"I thought I would give the Xceed WPF DataGrid (it's free!) a whirl with Entity Framework databinding. So far I have only explored the basics - no anonymous types or sprocs and I am only working with a READ-ONLY scenario. (I did notice something in their docs about being able to modify and delete but not add when binding to LINQ to SQL queries.) I have, however, at least used a multi-level object graph.

Here's what I've come up with.

Add the grid

  1. Drop an Xceed WPF DataGrid on a WPF Window

Preparing the data

  1. I created an EDM from AdventureWOrksLT. The namespace is awModel and the EntityContainer is awEntities. I also fixed up some naming, plurazing the EntitySets and the navigation properties that point to collections. (This is my standard routine when creating EDMs)
  2. In the Loaded event for the WIndow, add the following
Dim aw = New awModel.awEntities
Me.DataGridControl1.ItemsSource = From ord In aw.SalesOrderHeaders.Include("Customer") _
Select ord
..."

An interesting example of using WPF, Databinding and the coming Entity Framework...

So much to learn... :)


Related Past Post XRef:
Xceed DataGrid for WPF 1.1 Released
Free Xceed DataGrid for WPF Now Available for Download
Free WPF DataGrid from XCEED (Coming Soon)

No comments: