Good day, HeshKodovtsy

I want to use a trigger on the focus of the button, while changing the boundaries of the object. But the trigger, as I understand it, is applied to one property. How do I apply a whole object when the trigger fires?

An example of what I want to apply when a trigger is triggered:

<Border.Background> <LinearGradientBrush> <GradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="#e7ebf7" Offset="0.0"></GradientStop> <GradientStop Color="#cee3ff" Offset="0.8"></GradientStop> </GradientStopCollection> </GradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> 

Thanks in advance for your answers.

  • Similarly, an object may well be a property value. For syntax see the @petya answer. - VladD

1 answer 1

 <Window.Resources> <Style x:Key="ButtonStyle" TargetType="Button"> <Style.Triggers> <Trigger Property="IsFocused" Value="True"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush> <GradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="#e7ebf7" Offset="0.0"/> <GradientStop Color="#cee3ff" Offset="0.8"/> </GradientStopCollection> </GradientBrush.GradientStops> </LinearGradientBrush> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </Window.Resources> 
  • one
    I would also put the LinearGradientBrush separately in resources, yet an independent entity. - VladD