gpt4 book ai didi

c# - WPF窗口阴影效果

转载 作者:IT王子 更新时间:2023-10-29 04:52:45 25 4
gpt4 key购买 nike

我是 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>

但是当我运行它的时候,影子并没有出现。我该怎么办,或者错误在哪里?

最佳答案

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>

关于c# - WPF窗口阴影效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13367249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com