开发者

XamlParseException when trying to access Image from Resource directory

开发者 https://www.devze.com 2023-02-22 00:23 出处:网络
Im using the following code to define a Ima开发者_JAVA百科geBrush in a Window or UserControl: <ImageBrush x:Key=\"WindowBackground\" Stretch=\"None\" ImageSource=\"pack://application:,,,/Resources

Im using the following code to define a Ima开发者_JAVA百科geBrush in a Window or UserControl:

<ImageBrush x:Key="WindowBackground" Stretch="None" ImageSource="pack://application:,,,/Resources/bg1.tif"/>

This works great, if I use it in my normal application.

But for my testing project when I'm trying to instantiate this, I always get a XamlParseException for this line.

Any hints how to avoid that?

   [TestMethod]
   public void TestMethod1()
   {
      MainWindow window = new MainWindow();
   }


I suspect that the /Resources/bg1.tif file is copied into the directory into which your application builds and runs (eg /bin/Debug), but not into the directory your test project builds into. You will probably need to add a post build step to copy this directory across to your test project build output dir.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号