【问题标题】:WPF SplashScreen class can not locate the embedded imageWPF SplashScreen 类找不到嵌入的图像
【发布时间】:2013-09-17 09:31:56
【问题描述】:

我正在尝试显示splash screen for my WPF application。基于某些条件,我必须加载我创建的两个图像之一。所以我必须使用SplashScreen 类而不是设置static image as flashscreen。这很简单,对我来说很有效。

我正在做类似以下的事情,(我已将两个图像都设置为嵌入式资源

string splashImage = string.Empty;
if (Condition)
  {
    splashImage = "ApplicationType1.png";
  }
else
  {
    splashImage = "ApplicationType2.png";
  }

SplashScreen screen = new SplashScreen(splashImage);
screen.Show(true);

这给了我例外,

找不到资源 ApplicationType1.png

【问题讨论】:

  • 您在项目层次结构中的何处添加了图像?
  • @nit 我试过了,没有运气。
  • @KentBoogaart 也试过了,没用。
  • 您可能需要将 ImageSource 设置为“/ProjectName;component/images/ApplicationType1.png”
  • @Omribitan 不,那没用。

标签: c# wpf splash-screen


【解决方案1】:

我终于明白了,

问题在于我添加的 .png 图像。我仍然不知道为什么它无法加载该特定图像。我刚刚得到了.jpg 图像,它工作正常。

它适用于Embedded ResourceResource 的构建操作

【讨论】:

  • 我也遇到了这个问题。我重新保存了.png。我使用的一些编辑工具增加了透明度,我认为这导致加载失败。不是错误消息说的找不到资源,而是格式错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-30
  • 2019-05-19
  • 2018-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多