Feb 6, 2011

Dynamically Loading XAP File inside a Silverlight Parent XAP.

Hello all, tonight I just had one of the developer asking for Dynamic Loading XAP file inside a XAP file, in Silvelight 4.
I knew very well that, over Internet people may get various helps, but I feel to share this concept by developing a small demo application prepared by me.

Following is the stuff which I had thought before Developing:

1. I will Create Default Silverlight Application with a Host Page (i.e, Web Site Project will be added too)

2. Add New Silverlight Child Application to it. Compile it and get XAP

3. Will Download the Child XAP file over Client and then load it into the Control.



Step by Step Go through:
(1). Simply Create New Silverlight appliation with a Web Application Project


Do following code inside XAML (just to show an appropriate User Interface)



(2). Add New Silverlight Applicatin Project, Name it as (ChildToLoad).
It will give us a xap file which we will be going to download in side our main project.
For better understanding, of other Silverlight features, I have taken below shown UserInterface and coded accordingly.




(3). To Download The xap File Dynamically, use WebClient object and then parse the downloaded stream into a .xap file Render it into a control and Load it as a UserControl





The Source Code for the above app can be downloaded from the below link
DynamcallyLoadingXAP_SL4.rar

Hope you enjoy it.

Do suggest your feedback so that I can Improve.
Thanks!!

2 comments:

  1. Very nice, i read ur blog regulary. i want to know more about silverlight4. i want to know about MVVM and WCF RIA service.
    Thanking You

    ReplyDelete
  2. Yes Ramkrishn, I am planning for the same, will post the same with in upcoming weeks, which will be in a "EASY TO UNDERSTAND" format.

    ReplyDelete