BrowserInteropHelper.IsBrowserHosted Propriété

Définition

Obtient une valeur qui spécifie si l’application Windows Presentation Foundation (WPF) actuelle est hébergée par le navigateur.

public:
 static property bool IsBrowserHosted { bool get(); };
public static bool IsBrowserHosted { get; }
static member IsBrowserHosted : bool
Public Shared ReadOnly Property IsBrowserHosted As Boolean

Valeur de propriété

true si l’application est hébergée par le navigateur ; sinon, false.

Exemples

L’exemple suivant montre comment l’utiliser BrowserInteropHelper.IsBrowserHosted pour déterminer s’il Page est hébergé dans un navigateur.

// 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";
}
' Detect if browser hosted
If BrowserInteropHelper.IsBrowserHosted Then
    ' Note: can only inspect BrowserInteropHelper.Source property if page is browser-hosted.
    Me.dataTextBlock.Text = "Is Browser Hosted: " & BrowserInteropHelper.Source.ToString()
Else
    Me.dataTextBlock.Text = "Is not browser hosted"
End If

Remarques

Un Page peut être indépendant de l’hôte et, par conséquent, peut être chargé dans plusieurs types d’hôtes différents, y compris un , un FrameNavigationWindowou un navigateur. Cela peut se produire lorsque vous disposez d’un assembly de bibliothèque qui contient une ou plusieurs pages, et qui est référencé par plusieurs applications hôtes autonomes et extensibles (application de navigateur XAML (XBAP)).

S’applique à