Nasıl yapılır: bir sayfanın tarayıcıda barındırılıp barındırılmadığını belirleme

Bu örnek Page , bir tarayıcıda barındırılıp barındırılmadığını nasıl belirleyebileceğinizi gösterir.

Örnek

, Page Ana bilgisayar belirsiz olabilir ve sonuç olarak, bir, veya tarayıcı dahil olmak üzere birkaç farklı konak türüne yüklenebilir FrameNavigationWindow . Bu durum, bir veya daha fazla sayfa içeren bir kitaplık derlemeniz varsa ve birden çok tek başına ve gözatılabilir (XAML tarayıcı uygulaması (XBAP)) ana bilgisayar uygulaması tarafından başvurulan bir kitaplık derlemesidir.

Aşağıdaki örnek, BrowserInteropHelper.IsBrowserHosted bir Page tarayıcıda barındırılıp barındırılmadığını belirlemede nasıl kullanılacağını göstermektedir.

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

Ayrıca bkz.