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

UWP(Uno/WinUI 3)应用标题栏图标不显示及标题异常求助

解决Uno/WinUI 3 UWP应用标题栏图标与窗口标题问题

一、修复标题栏应用图标不显示问题

  • 确认清单图标配置:在Package.appxmanifest中,确保已正确指定SmallLogo(需包含16x16、32x32适配尺寸),标题栏默认调用该尺寸图标。示例配置如下:
    <uap:VisualElements
        DisplayName="你的应用名称"
        Square150x150Logo="Images\Square150x150Logo.png"
        Square44x44Logo="Images\Square44x44Logo.png"
        SmallLogo="Images\SmallLogo.png"
        Description="你的应用描述"
        BackgroundColor="#FFFFFF">
    
  • 代码强制指定图标:若清单配置未生效,可在窗口初始化代码(如App.xaml.cs或主窗口的构造函数)中添加以下代码:
    if (Window.Current.CoreWindow != null)
    {
        var titleBar = ApplicationView.GetForCurrentView().TitleBar;
        titleBar.SetIcon(new Uri("ms-appx:///Images/SmallLogo.png"));
    }
    
    注意使用ms-appx:///协议确保资源路径被正确解析。

二、修改窗口标题为自定义名称

  • 修正清单显示名称配置:检查Package.appxmanifest,确保<uap:VisualElements>节点内的DisplayName已设置,同时同步更新<Properties>节点下的DisplayName:
    <Properties>
        <DisplayName>你的应用名称</DisplayName>
        <PublisherDisplayName>你的发布者名称</PublisherDisplayName>
        <Logo>Images\StoreLogo.png</Logo>
    </Properties>
    
  • 代码强制设置标题:在窗口加载时(如主窗口的Loaded事件或构造函数)添加代码覆盖默认标题:
    ApplicationView.GetForCurrentView().Title = "你的应用名称";
    
    若使用WinUI 3 Desktop模式的AppWindow,可改用以下代码:
    var appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(MainWindowHandle));
    appWindow.Title = "你的应用名称";
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 17:40:57