As playing around a bit with the WP7 functionality, I wanted to create a small sample, which loads XAML Elements dynamically into the Page. No magic here.
The XAML fragment to be loaded has been extracted to a file called XamlFragment.xaml. I set in the Properties window of VS 2010 the Build Action to Content and deleted the value for the Custom Tool.
The idea was to package the file withe the XAP file and deploy it, so the SL App could read the file directly.
What I totally forgot about was the fact, that SL Apps have only access to the Isolated Storage. But the Isolated Storage in fact is a subfolder of the Apps folder, where the XAP files get deployed. So how to access the file?
After searching a bit around I found out, that XNA has the same issue on accessing files like textures etc., which are packed within the XAP.
Therefore the Assembly Microsoft.Xna.Framework contains the static class TitleContainer.
Executing “TitleContainer.OpenStream(‘XamlFragment.xaml’)” returned an object of type stream, which could be accessed by my StreamReader.
(Please keep in mind that this stream is readonly)
More info on the TitleContainer class can be found here.
The post Tip: Accessing Content Build files in WP7 appeared first on Windows Phone Development.