BrowserInteropHelper.IsBrowserHosted Properti

Definisi

Mendapatkan nilai yang menentukan apakah aplikasi Windows Presentation Foundation saat ini (WPF) dihosting browser.

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

Nilai Properti

true jika aplikasi dihosting browser; jika tidak, false.

Contoh

Contoh berikut menunjukkan cara menggunakan BrowserInteropHelper.IsBrowserHosted untuk menentukan apakah dihosting Page di 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";
}
' 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

Keterangan

Dapat Page menjadi host agnostik dan, akibatnya, dapat dimuat ke dalam beberapa jenis host yang berbeda, termasuk Frame, NavigationWindow, atau browser. Ini dapat terjadi ketika Anda memiliki rakitan pustaka yang berisi satu atau beberapa halaman, dan yang dirujuk oleh beberapa aplikasi host mandiri dan dapat dijelajahi (XAML browser application (XBAP)).

Berlaku untuk