How to make Style.Triggers trigger a different named style to be applied

I don't think you can however, you can reuse a style this way :

<Style x:Key="ActiveStyle" TargetType="{x:Type TextBox}">
    <Style.Triggers>
        <Trigger Property="IsFocused" Value="true">
            <Setter Property="BorderBrush" Value="Green" />
            <Setter Property="BorderThickness" Value="2" />
        </Trigger>
    </Style.Triggers>
</Style>

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource ActiveStyle}">
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="BorderBrush" Value="Gray" />
</Style>

I don't see another solution :(


There is yet a third way to do this.

Create two named control templates for your control:

<ControlTemplate x:Key="NotFocused" TargetType="{x:Type TextBox}">  
    . . .
</ControlTemplate>  

<ControlTemplate x:Key="Focused" TargetType="{x:Type TextBox}">   
    . . .
</ControlTemplate>

Then you create a default style for the TextBox with the triggers in it:

<Style TargetType="{x:Type TextBox}">   
    <Style.Triggers>
        <Trigger Property="IsFocused" Value="True">
            <Setter Property="Template" Value="{StaticResource Focused}" />
        </Trigger>
        <Trigger Property="IsFocused" Value="False">
            <Setter Property="Template" Value="{StaticResource NotFocused}" />
        </Trigger>
    </Style.Triggers>
</Style>

Tony