动态添加阴影效果到Silverlight边框?

时间:2012-03-03 16:03:22

标签: c# silverlight code-behind

我想动态地将DropShadowEffect添加到我的Silverlight边框,但是无法弄清楚C#语法......

                <Border BorderThickness="1"
                        CornerRadius="5"
                        Background="{StaticResource PanelBackground}"
                        BorderBrush="{StaticResource PanelBorderBrush}"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Margin="0,8,0,0"
                        Width="250">
                    <Border.Effect>
                        <DropShadowEffect />
                    </Border.Effect>
                </Border>

我可以创建边框很好的边框。影响我遇到了麻烦。

保罗。

1 个答案:

答案 0 :(得分:4)

System.Windows.Media.Effects.DropShadowEffect dropShadowEffect = new System.Windows.Media.Effects.DropShadowEffect();
dropShadowEffect.Opacity = 0.25;
dropShadowEffect.ShadowDepth = 5;
dropShadowEffect.BlurRadius = 10;
dropShadowEffect.Color = Colors.Black;
this.image.Effect = dropShadowEffect;

来源http://msdn.microsoft.com/en-us/library/system.windows.media.effects.dropshadoweffect.aspx

<Border Name="border">
            <Border.Effect>
                <DropShadowEffect/>
            </Border.Effect>
        </Border>

    this.border.Effect = dropShadowEffect;