I want to be able to have a generic style template that can switch colors of my textboxes based on a bool. But I don\'t want to have to create a unique style for each textb
You can use the Tag property of TextBox
<TextBlock Text="{Binding Text1}" Style={DynamicResource MyTextBoxTemplate} Tag="{Binding MyBool1}" />
<TextBlock Text="{Binding Text2}" Style={DynamicResource MyTextBoxTemplate} Tag="{Binding MyBool2}" />
<TextBlock Text="{Binding Text3}" Style={DynamicResource MyTextBoxTemplate} Tag="{Binding MyBool3}" />
<Style x:Key="MyTextBoxTemplate" TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="Tag" Value="True">
<Setter Property="Foreground" Value="Green" />
</Trigger>
<Trigger Property="Tag" Value="False">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
You can also use an attached property for that instead of Tag.