views:

80

answers:

1

Hello,

I have a VS2010 solution with 5 projects. Two of these projects are called:

MyResources Application

The Application project contains all of the views and viewmodels for the application to run, and the Resources project contains all the images, resource dictionaries, etc for theming and skinning.

The way I have images set up in Resources, I have their build action set to Content, and Copy set to Copy Always. In my Application project, I reference these files using a pack URI. Example:

"pack://siteoforigin:,,,/Themes/DefaultTheme/BackgroundImage.png"

This works fine for me. The themes folder and all its subfolders are properly copied to the proper folder since I'm using siteoforigin://.

However, this breaks Blendability. When I load the project in Blend 4, I get errors.

If I use siteoforigin, Blend tries to load the images from the executing folder of blend.exe (In this case, C:\Program Files\Microsoft Expression\Blend 4 Beta\Themes\Default_Theme\BackgroundImage.png")

If I change the pack URI to the following:

pack://application:,,,/IQ.IQKiosk.Resources;component/Themes/DefaultTheme/BackgroundImage.png

It tries to look for the image in "themes/default_theme/backgroundimage.png"

If I try:

/MyResources;component/Themes/DefaultTheme/BackgroundImage.png

It tries to look for the image in "C:\MyResources;component\Themes\DefaultTheme\BackgroundImage.png"

If I try:

/Themes/DefaultTheme/BackgroundImage.png

It tries to look for the image in "C:\Themes\DefaultTheme\BackgroundImage.png".

So now I'm stuck. I'm not sure how to reference my images without having to embed them into the resource project, and I can't hard code the directory because my other coworkers have the project in different folders as well.

I tried to think of a way to get the proper URI to the proper locations of the files (relative to the .sln file would be awesome) or have the files get copied over to where blend compiles and executes the project. Alas, I am unable to figure out how.

Does anyone know the proper way to get these images to load?

A: 

I figured it out. Instead of using a pack URI, I just used

new Uri(Environment.CurrentDirectory + "\\Themes\\DefaultTheme\\BackgroundImage.png")

and it found the proper folder, since Evironment.CurrentDirectory gave me the proper bin folder where my themes were copied to.

Huzzah!

Willson Haw