向Silverlight边框动态添加阴影效果

本文关键字:阴影 添加 动态 Silverlight 边框 | 更新日期: 2023-09-27 18:26:37

我想在Silverlight边框中动态添加DropShadowEffect,但无法理解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>

我可以创建边界精细它的边界。效果我有问题。

保罗。

向Silverlight边框动态添加阴影效果

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;