c# - 设置 showdialog 设置的图标
问题描述
有没有办法将图标添加到对话框。
这是我为对话框创建设置的地方:
dynamic settings = new ExpandoObject();
settings.WindowStartupLocation =
WindowStartupLocation.CenterOwner;
settings.WindowStyle = WindowStyle.SingleBorderWindow;
settings.ResizeMode = ResizeMode.NoResize;
settings.Title = "System Error";
//settings.(set my icon here);
status.UpdateMessage(ex.Message, $"{ex.Message} To the products list");
_window.ShowDialog(_status, null, settings);
解决方案
我假设我们正在谈论标题栏最左侧的图标。
一种方法是这样的(在您的 ExpandoObject 构造函数中):
Uri iconUri = new Uri("PathToYourIcon");
Icon = BitmapFrame.Create(iconUri);
有关更多详细信息,请参阅:如何在 wpf 中的代码中设置窗口图标?
您还应该能够在 XAML 模板中设置 Window 的 Icon 属性。毕竟,对话框应该只是一个窗口,就像任何其他窗口一样。
推荐阅读
- python - Python用科学记数法显示5.26E-325是0,但5.26E-324是5e-324,为什么?
- tableau-api - 如何在 Tableau 中将固定长度的字符串转换为多列
- java - 使用 ACS 智能卡读卡器获取 Mifare Keys (A & B)
- java - 即使将 jar 添加到类路径中,也没有找到类定义错误
- python - 在 requirements.txt 中强制重新安装 pip
- android - 如何通过电子邮件在 android 应用程序中实现 otp 功能
- zip - 压缩中断时磁盘上压缩文件的完整性
- python - 什么都不做的Django错误?
- ios - 推送通知 IOS:标准有效负载格式
- css - 如何通过溢出隐藏的子文本来防止父扩展?