I have a series of TextBlocks to which I want apply a Style and DataTrigger. The only difference is that the Binding is to a different property in the view model for each one.
Here is a simplified version of one of the TextBlocks with the Style and DataTrigger "built in".
<TextBlock Text="Is development">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDevelopmentIsDirty}"
Value="True">
<Setter Property="FontWeight"
Value="Bold" />
<Setter Property="FontStyle"
Value="Italic" />
<Setter Property="Foreground"
Value="{StaticResource SCB_TardisBlue}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
So, in the preceding example, the "IsDevelopmentIsDirty" binding would be different for each TextBlock.
I'm just not having the greatest luck in finding the best way to consolidate this Style into one declaration that can be used by the entire series of TextBlocks.
Is there a way to assign the style and the property to which the DataTrigger should bind? If not, what is a way to do this? My thanks in advance.