25

私はWPFテクノロジーに不慣れです。WPF に次のウィンドウ宣言があります。

<Window x:Class="CustomWindows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="480" Width="640" ScrollViewer.VerticalScrollBarVisibility="Disabled" WindowStyle="None" AllowsTransparency="True">
    <Window.Effect>
        <DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/>
    </Window.Effect>
    <Grid>

    </Grid>
</Window>

しかし、実行すると影が表示されません。どうすればよいですか、またはどこが間違っていますか?

4

1 に答える 1

54

DropShadowEffectには適用できませんWindow。代わりに、デフォルトのウィンドウの外観をオーバーライドしたい場合は、ウィンドウに含まれる他の要素に効果を適用する必要があります。

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" WindowStyle="None"
        AllowsTransparency="True" Background="Transparent">

    <Grid Margin="20" Background="Red">
        <Grid.Effect>
            <DropShadowEffect BlurRadius="15" Direction="-90"
                              RenderingBias="Quality" ShadowDepth="2"/>
        </Grid.Effect>
        ...
      
    </Grid>
</Window>
于 2012-11-13T19:33:18.797 に答える