Freigeben über


How to: Animate a Glow Effect

This example shows how to animate the GlowSize property of an OuterGlowBitmapEffect.

Example

The following example animates changes to the GlowSize property of the OuterGlowBitmapEffect. As a result, the glow animates outward when the TextBox gets focus.

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >

  <StackPanel>


    <TextBox Width="200">
      <TextBox.BitmapEffect>

        <!-- This BitmapEffect is targeted by the animation. -->
        <OuterGlowBitmapEffect x:Name="myOuterGlowBitmapEffect"  
         GlowColor="Blue" GlowSize="0" />

      </TextBox.BitmapEffect>
      <TextBox.Triggers>
        <EventTrigger RoutedEvent="TextBox.GotFocus">
          <BeginStoryboard>
            <Storyboard>

              <!-- Animate the GlowSize from 0 to 40 over half a second. --> 
              <DoubleAnimation
                Storyboard.TargetName="myOuterGlowBitmapEffect"
                Storyboard.TargetProperty="GlowSize"
                From="0" To="40" Duration="0:0:0.5" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </TextBox.Triggers>
    </TextBox>

  </StackPanel>

</Page>

For the complete sample, see Bitmap Effects Gallery Sample.

See Also

Tasks

How to: Create a Glow Effect on the Outer Edge of an Object
How to: Animate a Blur Visual Effect
How to: Animate a Drop Shadow Visual Effect
How to: Animate Multiple Visual Effects

Reference

GlowSize
OuterGlowBitmapEffect
TextBox

Concepts

Bitmap Effects Overview

Other Resources

Bitmap Effects Gallery Sample
Bitmap Effects How-to Topics
Bitmap Effects Samples