I'm generating a xaml from the code behind of a WPF application and want to add styles to the generated xaml. I'm using a resource dictionary to store the styling info which my app will access and apply to the appropriate elements in the generated xaml based on keys in the resource dictionary. Now I want to apply a specific style to all textboxes in the generated xaml. What I'm trying to do is to create this style in the resource dictionary without a key and I want to add this style resource to the resources of the generated xaml. I can't seem to find a way to add a particular resource to the resource dictionary of this generated xaml without a key. My questions is, is it possible to do so, i.e. add a resource to the resource dictionary of a usercontrol (or window etc.) without a key for that resource?
For example, here is the XAML I want to generate:
<UserControl>
<UserControl.Resources>
<Style TargetType="{x:Type TextBox}">
<!--The TextBox style-->
</Style>
</UserControl.Resources>
</UserControl>
Thanks!