Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
 InitParams Property

  Switch on low bandwidth view
.NET Framework Class Library for Silverlight
StartupEventArgs..::.InitParams Property

Gets the initialization parameters that were passed as part of HTML initialization of a Silverlight plug-in.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
Public ReadOnly Property InitParams As IDictionary(Of String, String)
    Get
Visual Basic (Usage)
Dim instance As StartupEventArgs
Dim value As IDictionary(Of String, String)

value = instance.InitParams
C#
public IDictionary<string, string> InitParams { get; }

Property Value

Type: System.Collections.Generic..::.IDictionary<(Of <(String, String>)>)
The set of initialization parameters, as a dictionary with key strings and value strings.

The initialization parameters are passed as the initParams parameter when you embed the Silverlight plug-in in a Web page. For more information, see Integrating Silverlight with a Web Page.

The input format of this parameter starts as a single string with individual parameters delimited using a comma (,), and keys delimited from values using an equal sign (=). For example, "key1=value1,key2=value2,key3=value3". The delimiters are processed so that this API can provide them as a dictionary.

You can also access the initialization parameters through the InitParams property.

The following example code demonstrates how to use this property.

Visual Basic
Private Sub Application_Startup(ByVal o As Object, _
    ByVal e As StartupEventArgs) Handles Me.Startup

    Dim p As New Page
    Me.RootVisual = p

    ' This assumes that Page.LayoutRoot exists and is a StackPanel.
    Dim layoutRoot As StackPanel = p.LayoutRoot

    ' Display the custom initialization parameters.
    For Each key As String In e.InitParams.Keys
        layoutRoot.Children.Add(New TextBlock With { _
            .Text = String.Format( _
                "from InitParams: {0} = {1}", _
                key, e.InitParams(key))})
    Next

    ' Display the URL parameters.
    For Each key As String In HtmlPage.Document.QueryString.Keys
        layoutRoot.Children.Add(New TextBlock With { _
            .Text = String.Format( _
                "from QueryString: {0} = {1}", key, _
                HtmlPage.Document.QueryString(key))})
    Next

End Sub

C#
private void Application_Startup(object sender, StartupEventArgs e)
{
    Page p = new Page();
    this.RootVisual = p;

    // This assumes that Page.LayoutRoot exists and is a StackPanel.
    StackPanel layoutRoot = p.LayoutRoot; 

    // Display the custom initialization parameters.
    foreach (String key in e.InitParams.Keys)
    {
        layoutRoot.Children.Add(new TextBlock() {
            Text = String.Format(
                "from InitParams: {0} = {1}", key, 
                e.InitParams[key])
        });
    }

    // Display the URL parameters.
    foreach (String key in HtmlPage.Document.QueryString.Keys)
    {
        layoutRoot.Children.Add(new TextBlock()
        {
            Text = String.Format(
                "from QueryString: {0} = {1}", key, 
                HtmlPage.Document.QueryString[key])
        });
    }            
}

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker