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

如何在macOS系统中通过Avalonia设置正确的应用标题?

解决macOS上Avalonia应用窗口标题显示为"Avalonia Application"的问题

方法1:XAML中直接设置窗口标题

在主窗口的XAML文件里,给Window标签添加Title属性,指定自定义名称:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="YourAppNamespace.MainWindow"
        Title="你的自定义应用标题">
    <!-- 窗口内容区域 -->
</Window>

方法2:代码后台动态设置标题

在主窗口的代码文件(如MainWindow.axaml.cs)中,在构造函数内设置Title属性:

public MainWindow()
{
    InitializeComponent();
    Title = "你的自定义应用标题";
}

方法3:配置macOS专属的Info.plist(必做)

macOS环境下,Avalonia应用的窗口标题会优先读取Info.plist的配置,需要同步修改这里的内容:

  1. 找到项目内的osx目录,打开其中的Info.plist文件
  2. 修改CFBundleDisplayName和CFBundleName字段的值为自定义名称:
<key>CFBundleDisplayName</key>
<string>你的自定义应用标题</string>
<key>CFBundleName</key>
<string>你的自定义应用标题</string>

修改完成后,重新生成并运行应用,或者重新打包发布,标题即可正常显示。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 17:35:58