2009-11-20 54 views
1

我想創建非矩形窗口與DropShadowEffect就可以了。我發現this文章如何做到這一點。然而這段代碼運行時DropShadowEffect沒有顯示。截圖上可以看到,DropShadowEffect是存在的,但它不是爲我工作。WPF DropShadowEffect與AllowsTransparency =「真」

如何,我可以使用DropShadowEffectAllowsTransparency設置爲True?

回答

7

我只是想將下面的代碼Kaxaml,並得到了圓角盒陰影。

Rounded box with drop shadow

我建議你試試Kaxaml也僅僅是用來做實驗,從你可能擁有的任何其他代碼分開。如果這個確切的代碼是而不是顯示陰影,那麼問題必須與您的系統。

<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

你說得對。此代碼適用於其他計算機,但不適用於我的計算機。感謝幫助。 – GTD 2009-11-20 09:01:42

相關問題