In my Silverlight 3 user control I am showing a basic DataGrid control. I need to generate the columns programmatically as
Based on Matt's answer, I came up with the solution of binding the header on the DataGridCellsPanel which in Snoop appeared to have the correct data context :
And this is non intrusive in the way that you can still inherits from custom styled headers (see exemple above) or event the base column header style:
This solution has the advantage of being pure and clean XAML and to refer to the closest ancestor holding the correct datacontext rather than trying to reach datacontext of top hierarchy elements like UserControl.