次の方法で共有


BrowserInteropHelper.IsBrowserHosted プロパティ

定義

現在のWindows Presentation Foundation (WPF) アプリケーションがブラウザーでホストされているかどうかを示す値を取得します。

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

プロパティ値

Boolean

アプリケーションがブラウザーによってホストされる場合は true。それ以外の場合は false

次の例では、BrowserInteropHelper.IsBrowserHosted を使用して Page がブラウザーでホストされているかどうかを確認する方法を示します。

// 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

注釈

Page はホストに依存しないので、FrameNavigationWindow、ブラウザーなど、さまざまな種類のホストに読み込むことができます。 これは、1 つまたは複数のページを含むライブラリ アセンブリがあり、複数のスタンドアロンおよび閲覧可能な (XAML ブラウザー アプリケーション (XBAP)) ホスト アプリケーションによって参照されている場合に、発生する可能性があります。

適用対象