Open a specific xaml page from a Silverlight control

0 comments
Each Silverlight application project may include multiple xaml pages. When you refer to a .xap file from a web page, the xaml page set using the Application.RootVisual property will be displayed by default.

There may be cases where you want different XAML files to be displayed when you refer to the same .xap file from different web pages. You can do this by passing the xaml file name or some other kind of identification using InitParameters property of the Silverlight control. This property can be set to the Silverlight control from the web page. The value set from web page will be read by the Silverlight control and appropriate xaml page will be opened.

To demonstrate this, let us create a sample Silverlight project with the name "OpenSpecificXaml". (You can read the steps to create a new Silverlight project.)

After you compile and build your project, place the Silverlight control in your web page as shown below:

<asp:Silverlight 
    InitParameters="PageName=Page1"
    ID="Xaml1" 
    runat="server" 
    Source="~/ClientBin/OpenSpecificXaml.xap" 
    MinimumVersion="2.0.30923.0" 
    Width="100%" Height="100%" />



In the above code, see the code:

InitParameters="PageName=Page1"

0 comments: