In WPF, how can I bind a datagrid column to a specific column of a datatable?

I have a Datatable with many columns, and a datagrid in which I need to display only a few of those columns. I need a codesample of how to do it. I found a whole bunch of examples telling me to turn AutoGenerateColumns to true and set the table as DataContext to display all the columns in my DataTable. And I guess I could then put in a page of code to hide all the columns that I don't need, rearrange the leftover ones to proper order and size, but surely there must be a more elegant way.

In designer I have build the collection of columns I want to display, I got the datable, how do I bind an existing datagrid column to a specific datatable column in my code?

8
задан Andrey 2 September 2010 в 17:37
поделиться