MEF with Silverlight 4

MEF – Managed Extensibility Framework. While building applications for SharePoint using Silverlight came across a scenario of dynamic loading of XAP and loading an application. The main reason moving towards this approach is scalability and to reduce the load time delay in loading the XAP files. This approach serves the request by dynamic loading of the content. I will come up with a simple application demonstrating MEF. Now I will post the quick ref links of MEF.

10 Reasons to use MEF


Part 1 , Part 2 , Part 3 , Part 4 , Part 5


Channel 9 Video series


Cloud Light Application submitted for Mix code challenge just 10Kb of size(More..)

Dynamically show image in Silverlight

I had a requirement to show images in Silverlight dynamically and that was quite simple can be done in two steps in a minute but I spend nearly hours to figure out the issue.

Dynamically show images from code behind

var bitmapImage = new BitmapImage(new Uri(“”);
image1.Source = bitmapImage;

The above code will make you smile only if you run the application from the silverlight web application project and not the default genarated testpage.html

The whole point is that this scenario works only if the application is hosted or run from an local web application with fileserver.

Note: Only JPG,PNG,BMP works this way and GIF doesn’t go well. Check this post to make GIF work