Reputation: 11
I want to change the border color of a text box when a user hovers his/her mouse over it. I tried this but failed.
<TextBox Name="a" Margin="20 50 50 150" >
<TextBox.Resources>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="Red"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Resources>
</TextBox>
Upvotes: 0
Views: 143
Reputation: 1064
You put the style in the TextBox
resource so it is not actually applied to it, it is only a resource. Try removing the resource tag, like this:
<TextBox Name="a" Margin="20 50 50 150" >
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="Red"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBox>
Upvotes: 1