views:

28

answers:

1

I am just learning to use the Entity framework and I wondered how I can bind to a select few columns with my WPF Toolkit datagrid?

Can someone give me an example?

I've tried to set the DataContext to the Person Entity for example and then set the Itemsource binding path to a single column of the table, but it does not work.

+2  A: 

You would do something more along the lines of a LINQ statement for the column you want, then binding to that variable. For example, if ctx is your data context:

var data = from p in ctx.Person
           select new { Name = p.Name };

That would give you an IQueryable list containing 1 variable with a Name field for each person. You would then bind to that list.

palehorse
Thanks! :) That was exactly what I needed!!
Tony
Glad to help :)
palehorse