c# - Styling from code behind -


I would like to have a WPF data-grid style behind my code, because the data-grid is built behind the code.

I have a resource dictionary in my resource with all the styles.

In XML, I will apply style to the data-grid as follows:

  style = "{StaticResource DataGridStyle}"   

I How can I get the data-grid created in the code back in this way:

  DataGrid dg = new datagreat ();   

Thanks in advance.

  dg.Style = This.Resources ["DataGridStyle"] style;    

Comments