If you want to
show the multiple Silverlight controls, there are two options.
Option #1: You can create multiple Silverlight projects and use them in ASP.NET. This is the easiest way to do.
Option
#2: If you don't want to create multiple projects then you can use
initParams of Silverlight control to pass the parameter from ASP.NET
project to Silverlight project.
For example:
Let's say we have one asp:Silverlight control in two content pages.
Content1 (aspx)
<asp:Silverlight ID="Silverlight1" InitParameters="PageId=1" runat="server" Height="100px" Width="100px">
</asp:Silverlight>
Content1 (html)
<div id="silverlightControlHost">
<object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
<param name="source" value="RichText.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="initParams" value="PageId=1" />
<a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
</a>
</object>
<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
Content2 (aspx)
<asp:Silverlight ID="Silverlight1" InitParameters="PageId=2" runat="server" Height="100px" Width="100px">
</asp:Silverlight>
Content2 (html)
<div id="silverlightControlHost">
<object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
<param name="source" value="RichText.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="initParams" value="PageId=2" />
<a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft
Silverlight" style="border-style: none"/>
</a>
</object>
<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
App.xaml.cs
private void Application_Startup(object sender, StartupEventArgs e){
int pageID = int.Parse(e.InitParams["PageId"]);
if(pageID == 1){
this.RootVisual = new Page1();
}
else{
this.RootVisual = new Page2();
}
}
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
Best Regards,
Michael Sync
Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed