BrowserInteropHelper.IsBrowserHosted プロパティ

定義

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

public:
 static property bool IsBrowserHosted { bool get(); };
public static bool IsBrowserHosted { get; }
static member IsBrowserHosted : bool
Public Shared ReadOnly Property IsBrowserHosted As 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)) ホスト アプリケーションによって参照されるライブラリ アセンブリがある場合に発生する可能性があります。

適用対象