Application.Host Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets various details about the Silverlight application's host.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public ReadOnly Property Host As SilverlightHost
public SilverlightHost Host { get; }

Property Value

Type: System.Windows.Interop.SilverlightHost
A SilverlightHost that provides various details about the Silverlight host application.

Remarks

Much of the information that is reported by a SilverlightHost object is the same information that could be obtained from properties of the Silverlight plug-in object in the JavaScript API. For instance, the Background color that was set as part of the Silverlight plug-in instantiation can be obtained from the Host.Background property. The "sub-objects" (Content and Settings) of the Silverlight plug-in in the JavaScript API are properties with object values (Content and Settings) in the managed API.

Examples

The following example shows how to use Host to get the path to the Silverlight application package.

Run this sample

<UserControl x:Class="SilverlightApplication.Page"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">

    <Grid>
        <TextBlock Text="{Binding Source}" />
    </Grid>

</UserControl>
Partial Public Class Page
    Inherits UserControl

    Public Sub New()

        InitializeComponent()

        Me.DataContext = App.Current.Host

    End Sub

End Class
using System.Windows.Controls; // UserControl

namespace SilverlightApplication
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();

            this.DataContext = App.Current.Host;
        }
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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