Just recently I started learning Silverlight and its pretty cool. I am loving it and trying to find new things everyday out of it.
Today, while working with the XAMLs and XAPs, I noticed that the Silverlight controls when referred onto an ASPX page, uses the XAP as the source.
Now thats where I had an issue.
I had created quite a few UserControls (XAMLs) on a single XAP and had no clue how to distinguish them on the ASPX page.
Here is the solution to it.
For the purpose of differenciating between the two controls, we use its InitParameters property.
As shown in the image above, I had multiple XAMLs for a single XAP
Now I had two ASCX user controls. One of them needed Page.Xaml and the other needed TeamToolbar.xaml.
So to distinguish between the two, I had the following declarations:
On the Page.Ascx -
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=Page" Width="100%" Height="100%">
And on the TeamToolbar.ascx -
<asp:Silverlight ID="Xaml2" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=TeamToolBar" Width="100%" Height="100%">
And on the App.xaml.cs, where its all initialized, we need to check which control is to be loaded.
In the Application_Startup method, this is how we need to check for it.: