You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Avalonia UI自定义无边框异形窗口:边框与阴影消除问题

在Avalonia UI中移除Windows 11窗口边框和阴影,仅保留自定义圆形内容

要解决Windows 11下Avalonia窗口仍残留边框、阴影的问题,只需调整核心属性并清理冗余配置:

  • 必须添加AllowTransparency="True"——这是Windows平台实现完全透明、消除系统阴影的关键开关
  • 移除ExtendClientArea相关属性(这类属性针对保留标题栏场景,和完全无装饰窗口冲突)
  • 确保WindowState="Normal",避免最大化状态下的阴影残留

修改后的完整XAML代码:

<Window xmlns="https://github.com/avaloniaui"
        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"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="avava.MainWindow"
        Width="200"
        Height="200"
        WindowStartupLocation="CenterScreen"
        Background="Transparent"
        TransparencyBackgroundFallback="Transparent"
        SystemDecorations="None"
        AllowTransparency="True"
        WindowState="Normal">
    <Ellipse Fill="Green" Opacity="0.5" Width="150" Height="150" StrokeThickness="10" Stroke="Blue"/>
</Window>

如果修改后仍有阴影残留,检查项目的.csproj文件,添加以下配置禁用Windows 11默认的Mica效果:

<PropertyGroup>
  <WindowsEnableMicaWindow>false</WindowsEnableMicaWindow>
</PropertyGroup>

内容的提问来源于stack exchange,提问作者Yegor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 18:22:48