Looks similar to this: EventTrigger with Setter in WPF?
You need to use EventTrigger
to get the functionality you want using only XAML. Notice that to get it work you should change the value of BorderThickness
to something that is not 1. If it is 1 (the default value), it will display standard 3d border.
<TextBox x:Name="tb" Width="150" Height="30" IsReadOnly="True" Text="Double click to type"
BorderBrush="Black" BorderThickness="0.99">
<TextBox.Triggers>
<EventTrigger RoutedEvent="TextBox.MouseDoubleClick" SourceName="tb">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0"
Storyboard.TargetProperty="(TextBox.IsReadOnly)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<sys:Boolean>False</sys:Boolean>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBox.BorderBrush).Color">
<EasingColorKeyFrame KeyTime="0:0:0.1" Value="Red"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="TextBox.LostFocus" SourceName="tb">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0"
Storyboard.TargetProperty="(TextBox.IsReadOnly)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<sys:Boolean>True</sys:Boolean>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBox.BorderBrush).Color">
<EasingColorKeyFrame KeyTime="0:0:0.1" Value="Black"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBox.Triggers>
</TextBox>