Introduction
If you are developing a Silverlight Application, and you need to pass some parameters inside – for example a key and value pair then we can pass the key value pair from the aspx page itself. We will see how we can do this in Silverlight.
Create a Silverlight Project

Figure 1.1 Creating Silverlight Project
Adding parameters
Open the "InitializingParametersTestPage.aspx" and find the tagtag <asp:Silverlight add an attribute InitParameters
- InitParameters="Key1=Value1,Key2=Value2"
In App.xaml.cs add an object of IDictionary<string,string> as follows
- public IDictionary<string, string> AppParams;
- In Application_Startup event initialize the parameters as follows
- private void Application_Startup(object sender, StartupEventArgs e)
- {
- AppParams = e.InitParams;
- this.RootVisual = new Page();
- }
In Page.xaml add ListBoxes to show the parameter values
Xaml Code
- <UserControl x:Class="InitializingParameters.Page"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Width="400" Height="300">
- <Grid x:Name="LayoutRoot" Background="#FFB7C2E5">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.472*"/>
- <ColumnDefinition Width="0.025*"/>
- <ColumnDefinition Width="0.502*"/>
- </Grid.ColumnDefinitions>
- <ListBox x:Name="myKeysList"/>
- <ListBox x:Name="myValuesList" Grid.Column="2"/>
- </Grid>
- </UserControl>
- namespace InitializingParameters
- {
- public partial class Page : UserControl
- {
- public Page()
- {
- InitializeComponent();
- App myApp = App.Current as App;
- foreach (string item in myApp.AppParams.Keys)
- {
- myKeysList.Items.Add(item);
- }
- foreach (string item1 in myApp.AppParams.Values)
- {
- myValuesList.Items.Add(item1);
- }
- }
- }
- }
When you run the application the list will carry the key and value pairs.

Figure 1.2 Displaying Key Value pair
Hope you like the article, Enjoy Coding.

Ruben BenayonPosted Jan 19, 2012, 10:32 AM
This is a great sample, but I need implement this to SMF player porjec. Can you help me to do this in the simple SMF project? I need pass in initParams the URL, and delivery method for example. Thank