Conmi的正确答案——Rider中添加icon作为exe的图标

C#版本:.net 8.0

Rider版本:#RD-243.22562.250(非商业使用版)


1、添加图标到解决方案下:


2、打开"App.xaml"配置文件,添加配置:

xml 复制代码
<Application
    x:Class="ComTransmit.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ImageSource x:Key="ComTransmitIcon">ComTransmitIcon.ico</ImageSource>
    </Application.Resources>
</Application>

3、打开"MainWindow.xaml"配置文件,添加配置:

xml 复制代码
<Window
    x:Class="ComTransmit.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"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
    <Window.Icon>
        <StaticResource ResourceKey="ComTransmitIcon" />
    </Window.Icon>
    <Grid />
</Window>
相关推荐
玩泥巴的2 小时前
飞书 .NET SDK 事件处理的幂等性与去重机制
c#·.net·二次开发·飞书
在路上看风景2 小时前
3.2 FileStream
c#
zwm2698888152 小时前
6号楼 部分声光24v电压达不到,显示11v
c#
椒颜皮皮虾6 小时前
TensorRtSharp:在 C# 世界中释放 GPU 推理的极致性能
c#·tensorrt
行止956 小时前
WinForms 彻底隐藏 滚动条的终极解决方案
c#
bugcome_com7 小时前
WPF样式进阶实战:外置样式+MVVM主题切换+样式优先级全解析
c#·.net·wpf
时光追逐者7 小时前
TIOBE 公布 C# 是 2025 年度编程语言
开发语言·c#·.net·.net core·tiobe
观无8 小时前
固高运动控制卡(GST800)基础应用分享
c#
flysh059 小时前
如何利用 C# 内置的 Action 和 Func 委托
开发语言·c#
逑之10 小时前
C语言笔记1:C语言常见概念
c语言·笔记·c#