Home / Programming / Blog article: Get URI Of Silverlight Plugin Host Page

| RSS

Get URI Of Silverlight Plugin Host Page

July 13th, 2009 | No Comments | Posted in Programming

Within our Silverlight application if we want to know the URI where our Silverlight content is running, we can tap into System.Windows.Browser namespace. This namespace contains object which are full of Browser related information. This is an example of retrieving the URI from within Silverlight application.

<StackPanel x:Name="LayoutRoot" Margin="10">
  <TextBlock Text="Your URL is: " />
  <TextBlock Text="{Binding AbsoluteUri}" />
</StackPanel>

 

In our C# code we can set the DataContext so that the second TextBlock above displays the information we desire.

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
  LayoutRoot.DataContext =
    System.Windows.Browser.HtmlPage.Document.DocumentUri;
}

 

Here is my output which displays the URL at which my Silverlight plugin is hosted.

image

Leave a Reply 2105 views, 2 so far today |

Leave a Reply





Switch to our mobile site