WPF获得焦点后如何让边框发光

当控件获得焦点后,外边框发光效果。由于.Net4取消了BitmapEffect类,只保留了Effect类。所以使用的是阴影效果实现。
2
3
4
5
6
7
8
9
10
11
<Style x:Key="OuterGlowStyle" TargetType="{x:Type FrameworkElement}">
    <Style.Triggers>
        <Trigger Property="IsFocused" Value="True">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect BlurRadius="10" Color="Black" Direction="0" Opacity="0.6"
 RenderingBias="Performance" ShadowDepth="0"/>
                </Setter.Value>
            </Setter>
        </Trigger>
    </Style.Triggers>
</Style>

 

  调用方法:

<TextBox Width="150" Style="{StaticResource OuterGlowStyle}" /

posted @ 2011-11-10 16:15  therockthe  阅读(4198)  评论(0)    收藏  举报