边界Dropshadow影响里面的内容

时间:2014-02-26 18:05:18

标签: c# wpf

我正在尝试设置带有阴影的边框,但问题是阴影不会出现在边框周围,而是出现在其内部的上下文中。我怎么能绕过边境?

代码:

<Border HorizontalAlignment="Left" VerticalAlignment="Top" CornerRadius="10" Margin="20" BorderBrush="Gray" BorderThickness=".5" Height="30">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.Effect>
                    <DropShadowEffect BlurRadius="12" Color="Black" Direction="315" Opacity="0.8"/>
                </Grid.Effect>
                <TextBlock Grid.Column="0" Text="Ex Dates Filter Start:13/02/2014 End 14/02/2014" Margin="5"/>
                <TextBlock Grid.Column="1" Text="X" Margin="0,0,5,0"/>
            </Grid>                        
        </Border>

1 个答案:

答案 0 :(得分:2)

将效果应用于border而不是Grid:

<Border>
  <Border.Effect>
     <DropShadowEffect BlurRadius="12" Color="Black" Direction="315"
                       Opacity="0.8"/>
  </Border.Effect>
  <Grid> ... </Grid>
</Border>

enter image description here