BrowserInteropHelper.IsBrowserHosted Property

Gets a value that specifies whether the current Windows Presentation Foundation (WPF) application is browser hosted.

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

public static bool IsBrowserHosted { get; }

Property Value

Type: System.Boolean
true if the application is browser hosted; otherwise, false.

A Page can be host agnostic and, consequently, can be loaded into several different types of hosts, including a Frame, a NavigationWindow, or a browser. This can happen when you have a library assembly that contains one or more pages, and which is referenced by multiple standalone and browsable (XAML browser application (XBAP)) host applications.

The following example demonstrates how to use BrowserInteropHelper.IsBrowserHosted to determine if a Page is hosted in a browser.

// Detect if browser hosted 
if (BrowserInteropHelper.IsBrowserHosted) 
{
    // Note: can only inspect BrowserInteropHelper.Source property if page is browser-hosted. 
    this.dataTextBlock.Text = "Is Browser Hosted: " + BrowserInteropHelper.Source.ToString();
}
else 
{
    this.dataTextBlock.Text = "Is not browser hosted";
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft