In my previos article i dicussed about how to Include Files as Resources and load them in Silverlight 2.0.
Files can be included in the application .xap package. A .xap file is simply a zip file containing the compiled output files. You can rename the .xap extension to .zip, and then unzip the contents. To include a file in application package, simply set the 'Build Action' to 'Content' and rebuild the solution.
To load the files from the application package use the following code:
using
new Uri("blue.png", UriKind.Relative));
BitmapImage bmp2 = new BitmapImage();
bmp2.SetSource(sr2.Stream);
Image2.Source = bmp2;
Note: The URI is now URI just "blue.png". If the images were stored in a subfolder 'Images', the URI would be "Images/blue.png".
Limitation
If Application.GetResourceStream() returns nothing or null, it may be due to: Visual Studio 2008 prevents the compiler from rebuilding the resources. The work around is to go to the project folder and delete all the *.resources files in the subfolders or just delete the 'Obj' folder and press F5 to run the solution.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: