微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WPF 窗口角半径和阴影

如何解决WPF 窗口角半径和阴影

我想要一个没有按钮、带有圆角和阴影的窗口。 像这样:

Like this

这是我的 XAML 代码

<Window x:Class="Password.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Password"
        mc:Ignorable="d"
        Title="MainWindow" Height="294" Width="546" Background="Transparent" Foreground="#FFE755DD" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen">
    <Grid >
        <Grid.Effect>
            <DropShadowEffect BlurRadius="20" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/>
        </Grid.Effect>
        <Border Background="#FF22173C" CornerRadius="20,20,20"/>
    </Grid>
</Window>

这是输出

And this is the output

阴影不是圆形的。 我该怎么办?

解决方法

模糊被裁剪,因为您的窗口不拥有它周围的空间。

设置 <Grid Margin="20"> 以允许在您控制的区域发生模糊。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。