Make sure your Windows Phone resources are in the top of your page

Last week I tried to implement the LongListSelector component in my Windows Phone application. After some Googling I found the following post that provides some basic steps to create a nice alphabetized group, similar to the selection in the contacts screen. The post instructs you to add two templates to the resource section of the page. For a newbie such as myself, this was not a really self-explanatory instruction so I decided to Google some more on Windows Phone and resource sections.

To make a long story shot, basically all that you need to do is to create a:
section and copy/paste the templates into it. Piece of cake right?

The simple answer is yes, but when you make a newbie mistake like I did, then you will wind up with a similar exception as the following one: "Cannot find a Resource with the Name/Key LongListGroupHeader [Line: 32 Position: 56]"

XamlParseException occured

This exception occured because I added the resource section in the bottom of the page (doh!). In this case the LongListSelector element is referring to resources that are not available.