Set binding for DataTemplate components in code

Posted by Chouppy on Stack Overflow See other posts from Stack Overflow or by Chouppy
Published on 2010-03-02T16:35:44Z Indexed on 2010/03/21 20:11 UTC
Read the original article Hit count: 322

Hi;

sorry if I'm not clear, it's not really clear in my head too (especially after trying to find my way in other posts :p)

What I'm willing to do is creating DataGrids in code, with zero to numerous columns containing a button, which will call one same function but with a "parameter" (different for each column).

Here is what I got so far : DataGrid created in code DataTemplate defined in the xaml resources (with a button) DataGridTemplateColumn which uses the above DataTemplate

Is it possible to bind the button's properties (in the DataTemplate), to the DataGridTemplateColumn properties (in my case, the column header would be ok), and how?

Is there a way to get an access to the DataTemplate components (the button for example) in code, and modify their properties?

Is it possible (and not hazardous) to create a DataTemplate in code? I declared mine in xaml because I found a post advising to do so instead of code.

Thanks for your help.

© Stack Overflow or respective owner

Related posts about datagridtemplatecolumn

Related posts about databinding