Loading

wpf动态效果

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="OuterGlowStyle" TargetType="{x:Type FrameworkElement}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect x:Name="OG" BlurRadius="0" Color="Black" Direction="0" Opacity="0.6" RenderingBias="Performance" ShadowDepth="0">
                        <Storyboard.TargetProperty>
                            BlurRadius
                        </Storyboard.TargetProperty>
                    </DropShadowEffect>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <EventTrigger RoutedEvent="GotFocus">
                    <BeginStoryboard Name="xx">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Effect).(DropShadowEffect.BlurRadius)" BeginTime="00:00:00" From="0" To="10" Duration="00:00:01" AutoReverse="True" RepeatBehavior="Forever"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>

                <EventTrigger RoutedEvent="LostFocus">
                    <StopStoryboard BeginStoryboardName="xx"/> 
                </EventTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="135,80,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Style="{StaticResource OuterGlowStyle}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="138,151,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" />
    </Grid>
</Window>

 

posted @ 2014-11-25 18:15  Sam Xiao  阅读(470)  评论(0)    收藏  举报