Reputation: 88187
Is there a way I can reuse Styles for more than 1 TargetType
eg. ComboBox and TextBox
<Style TargetType="ComboBox, TextBox" />
is there such a thing? Or is the only way duplicate the style and target each style to differnt types?
Upvotes: 0
Views: 929
Reputation: 1313
You can't (if I'm not mistaken). But what you may do in order to avoid copy-paste is to create a BaseStyle with a key and then create two styles for ComboBox and TextBox which are BasedOn the BaseStyle. smth like that:
<Style x:Key="BaseStyle" TargetType="{x:Type Control}">
<Setter ... />
</Style>
<Style BasedOn="{StaticResource BaseStyle }" TargetType="{x:Type ComboBox }" />
<Style BasedOn="{StaticResource BaseStyle }" TargetType="{x:Type TextBox}" />
Upvotes: 3
Reputation: 135
Instead of this you can provide targettype as control and define setter proeprties of control and apply that style to textbox and combox.
Upvotes: 0