Compartilhar via


WP7 Perf Tip #4: Use fully qualified paths when setting the source property

File this one under "Sad, but True"...

Take Away's:

Always prefix your source paths with a "/" (full-qualified path) instead of simply using relative paths.

Correct:

  <Image Source=" / Resources/Images/Background.jpg"> 

Incorrect:

  <Image Source="Resources/Images/Background.jpg"> 

But they both work!?!

True, both of these will work, equally well (visually), but performance wise the relative path will do extra lookups which waste time, and can hit the SD card more than you want it to (causing further slow downs). This is something that we will fix on our side in the future - since all storage is isolated and we can assume that there is always a "/" (if there is no ".."). For now, it doesn't hurt to get the extra performance boost by simply prefixing your paths with a "/".

Note:

As Luke Kim, a friend from Microsoft, pointed out "/" paths are not really full qualified paths. To make things clear though, I use the term "full qualified" since we are within the confines of the .NET IsolatedStorage framework and there is no access to the rest of the system, "/" paths are as fully qualified as you get (without actual URI specifiers). Thanks for pointing this out!