开发者

WPF DropShadowEffect with AllowsTransparency="True"

开发者 https://www.devze.com 2022-12-11 19:58 出处:网络
I want to create Non-Rectangular Window with DropShadowEffect on it. I found this article how to do开发者_Go百科 this. However DropShadowEffect is not shown when running this code. On screenshots you

I want to create Non-Rectangular Window with DropShadowEffect on it. I found this article how to do开发者_Go百科 this. However DropShadowEffect is not shown when running this code. On screenshots you can see that DropShadowEffect is present, but it's not working for me.

How I can use DropShadowEffect with AllowsTransparency set to True?


I just tried the following code in Kaxaml and got a rounded box with a drop shadow.

WPF DropShadowEffect with AllowsTransparency="True"

I suggest you try Kaxaml too, just to separate your experiments from whatever other code you might have. If this exact code does not show a drop shadow, then the problem must be with your system.

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  WindowStartupLocation="CenterScreen"
  WindowStyle="None"
  AllowsTransparency="True"
  Background="Transparent"
  >
  
<Border CornerRadius="10"
        BorderBrush="Gray"
        BorderThickness="3"
        Background="AliceBlue"
        Margin="24"
        Padding="4"
        Width="100"
        Height="100"
        >
  <Border.Effect>
    <DropShadowEffect Color="Gray"
                      Opacity=".50"
                      ShadowDepth="16" />
  </Border.Effect>
  
  <Grid Background="AliceBlue">
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Hello world.</TextBlock>
  </Grid>
  </Border>
</Window>
0

精彩评论

暂无评论...
验证码 换一张
取 消