Share via


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 或 瀏覽器。 當您有一個包含一或多個頁面的程式庫元件,而且由多個獨立和可流覽的 (XAML 瀏覽器應用程式 (XBAP) ) 主應用程式參考時,就會發生這種情況。

適用於