1

I tried to change the behaviour of my textboxes so that they change their borderbrush if someone hovers over them. At the same time I want my textboxes to stay green bordered if someone types in it. I first tried the hover over thing and created this piece of code:

<Style TargetType="{x:Type TextBox}">
        <Style.Triggers>
            <Trigger Property="TextBox.IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="Green"/>
                <Setter Property="BorderThickness" Value="2"/>
            </Trigger>
            <Trigger Property="TextBox.IsMouseOver" Value="False">
                <Setter Property="BorderBrush" Value="Black"/>
                <Setter Property="BorderThickness" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

The problem comes by adding the triggers for the IsKeyboardFocused event. If i add these two extra triggers, everything is working except the hover over parts. So my textbox won't get a green border if i hover over it.

Is there anyway to solve this or combine two triggers like If IsMouseOver==true && IsKeyboardFocused == false then borderbrush = green ?

Thanks in advance!

H.B.
  • 166,899
  • 29
  • 327
  • 400
TorbenJ
  • 4,462
  • 11
  • 47
  • 84

1 Answers1

3

MultiTrigger triggers on a logical-AND combination of conditions. There is no logical-OR MultiTrigger, though.

Anton Tykhyy
  • 19,370
  • 5
  • 54
  • 56