Aug
14
Creating a TextBox with growing and shrinking glow
Category: WPF
Posted by: Martin Rauscher
This shouldn't be to hard for anyone with basic WPF knowledge, but it's quite nice, so I thought I'd share it.
Mind that this style uses BitmapEffects which are depreciated from .NET 3.5 SP1 on.But there is no OuterGlowEffect at the moment, and it shouldn't really hurt performance, unless you can click REALLY fast ;)
Update:
Well, there is no OuterGlowEffect but you can achieve the same result with a DropShadowEffect if you change the angle... *ups* :)

Please tell me if you found a usable non-BitmapEffect for OuterGlow.
Mind that this style uses BitmapEffects which are depreciated from .NET 3.5 SP1 on.
Update:
Well, there is no OuterGlowEffect but you can achieve the same result with a DropShadowEffect if you change the angle... *ups* :)

- <br />
- <Style TargetType="{x:Type TextBox}"><br />
- <Setter Property="Template"><br />
- <Setter.Value><br />
- <ControlTemplate x:Key="{x:Type TextBox}"><br />
- <Border BorderBrush="Black" BorderThickness="1" <br />
- SnapsToDevicePixels="True" <br />
- Width="Auto" Height="Auto" <br />
- Background="White"<br />
- x:Name="PART_ContentHost"><br />
- <Border.BitmapEffect><br />
- <OuterGlowBitmapEffect <br />
- GlowColor="CornflowerBlue" <br />
- GlowSize="0" x:Name="myGlow"/><br />
- </Border.BitmapEffect><br />
- </Border><br />
- <ControlTemplate.Triggers><br />
- <Trigger Property="IsEnabled" Value="False"><br />
- <Setter Property="Background" Value="Gray"/><br />
- </Trigger><br />
- <EventTrigger RoutedEvent="UIElement.GotFocus"><br />
- <BeginStoryboard><br />
- <Storyboard><br />
- <DoubleAnimation <br />
- Storyboard.TargetName="myGlow" <br />
- Storyboard.TargetProperty="GlowSize" <br />
- To="6" Duration="0:0:0.1"/><br />
- </Storyboard><br />
- </BeginStoryboard><br />
- </EventTrigger><br />
- <EventTrigger RoutedEvent="UIElement.LostFocus"><br />
- <BeginStoryboard><br />
- <Storyboard><br />
- <DoubleAnimation <br />
- Storyboard.TargetName="myGlow" <br />
- Storyboard.TargetProperty="GlowSize" <br />
- To="0" Duration="0:0:0.1"/><br />
- </Storyboard><br />
- </BeginStoryboard><br />
- </EventTrigger><br />
- </ControlTemplate.Triggers><br />
- </ControlTemplate><br />
- </Setter.Value><br />
- </Setter><br />
- </Style><br />


ofthey wrote: