Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>**EDIT :-</p> <p>You can style the DataGridColumnHeader and do some funky bindings. try <a href="http://sites.google.com/site/wpfprojects/" rel="nofollow noreferrer">here</a> and download the ColumnHeaderBindings.zip, it has a little test project, that is a bit of a hack, but it works</p> <p>**End Edit</p> <p>The <strong>Binding</strong> on the column happens on a <strong>per row</strong> basis, the column is not part of the visual tree, the binding gets applied to each item in the grid, from the grids source code you can see that the property Binding has these comments</p> <pre><code> /// &lt;summary&gt; /// The binding that will be applied to the generated element. /// &lt;/summary&gt; /// &lt;remarks&gt; /// This isn't a DP because if it were getting the value would evaluate the binding. /// &lt;/remarks&gt; </code></pre> <p>So binding to the columns does not make much sense, because as you have found out, when you are not part of the visual tree you have no data context.</p> <p>The same problem exists with the ComboBoxColumn when you want to bind to the items source. You can bind to a StaticResource, but StaticResources dont have a data context either. You could use an object data provider or just instantiate directly in xaml.</p> <p>but i would just create the columns in code, and set the header. this problem would just go away then.</p> <p>there is a good article <a href="http://blogs.msdn.com/vinsibal/archive/2008/08/14/wpf-datagrid-dissecting-the-visual-layout.aspx" rel="nofollow noreferrer">here</a> on the visual layout.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload