views:

1982

answers:

2

Basically I would like to be able to do something like this in my xaml:

<Image Source="Resources/logout.png" />

and have it find Resources/logout.png as a file in my xap file, without going back to the web server. I also want to be able to rebuild my xap file on the fly, so placing it as a resource in a dll is not acceptable.

Any ideas?

+1  A: 

Add the images to the project, but set the Build Action to Content and Copy to Output Directory to Do not copy.

For a file in the root directory, I used this format.

<Image Source="/logout.png" />
BenMaddox
A: 

I would suggest not doing this because it will make your initial XAP download take much longer.

Michael S. Scherotter
If it's on the main page, I'd disagree. Otherwise, yeah you have a point. So no + but no - either :)
jcollum
This approach is ok if the amount of content to be embedded is small. I agree with your point, if it is large content. Best practice here is to make a judgement call on the size, and test.
pearcewg
I believe there are plenty of situations where embedding the key resources (imagine toolbar icons, UI components, and basic app branding) is better. It's one less HTTP request, it'll end up being compressed ever so slightly (in the .xap), etc.
Jeff Wilcox
This negates the ability for the browser or the CDN to cache individual elements that don't change frequently. Application usage also factors into it. If the usage pattern is single usage, then you're correct, putting it into the XAP makes sense. If the usage pattern is one where people use the app over and over and the XAP might change often, then using a combination and browser/CDN and ISO Storage caching will get a better-performing app that is quicker to load.
Michael S. Scherotter