Export (0) Print
Expand All

Application.Host Property

Gets various details about the Silverlight application's host.

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

public SilverlightHost Host { get; }

Property Value

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

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.

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

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

</UserControl>



using System.Windows.Controls; // UserControl

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

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


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

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

Community Additions

Show:
© 2014 Microsoft