Reputation: 1327
I would like to style a WPF data-grid from my code behind, as the data-grid is created in code behind.
I have a resource dictionary in my application with all styles.
In XAML I would apply the style to the data-grid as follows:
Style="{StaticResource DataGridStyle}"
How can I achieve this for a data-grid created in code behind as follows:
DataGrid dg = new DataGrid();
Thanks in advance.
Upvotes: 2
Views: 316