I have been working on a Silverlight Navigation application which uses LINQ to query an XML data source and has been working without a hitch until I added a control to the landing page. All other pages which worked fine were loaded from the navigation service Once I added the control I got a page not found error! (The page is there) and If navigated to, it works as expected. What happens, it that I closed the error Modal dialog and then clicked on another page, then navigate back to the landing page it works! However, the page doesn’t load on initialization.
I thought the issue is with the data access timing. Because the data access (LINQ query) is asyncronomous it hasn't finished retrieving data before the control on the page is requesting the data. If I single step through the code I see a The typical object error when trying to access the collection being filled from the data access code.
On my Development Computer, I do not have an issue as I have a dummy data source to query against and the Page loads fine!
So the issue seems to be that I need to put a delay of some sort before the controls are loaded. Basically the entire application loaded some data from an xml file gathered from a SharePoint list.
I found the solution by re-querying the data source and after the data loaded, I added my control to the page controls collection dynamically.
This was my first ever issue with asyncronomous programming and it is a lesson which will be ingrained into my Silverlight development forever as I had a few hours of debugging to help chisel it into my brain housing group!