DesktopWindowXamlSource 類別

定義

例如,啟用非 UWP 傳統型應用程式 (,WPF 或Windows Forms應用程式) 在任何與視窗控制碼相關聯的 UI 元素中裝載 UWP 控制項, (HWND) 。

/// [Windows.Foundation.Metadata.ContractVersion(Windows.UI.Xaml.Hosting.HostingContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DesktopWindowXamlSource : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.UI.Xaml.Hosting.HostingContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class DesktopWindowXamlSource : System.IDisposable
Public Class DesktopWindowXamlSource
Implements IDisposable
繼承
Object IInspectable DesktopWindowXamlSource
屬性
實作

Windows 需求

裝置系列
Windows Desktop Extension SDK (已於 10.0.17763.0 引進)
API contract
Windows.UI.Xaml.Hosting.HostingContract (已於 v3.0 引進)

備註

DesktopWindowXamlSourceUWP XAML 裝載 API中的主要類別。 此 API 可讓非 UWP 傳統型應用程式裝載任何衍生自 Windows.UI.Xaml.UIElement 的控制項,) 與視窗控制碼相關聯, (HWND) 。 使用 WPF、Windows Forms和 Windows API (Win32) 建置的桌面應用程式可以使用此 API。 如需詳細資訊,請參閱 在傳統型應用程式中使用 UWP XAML 裝載 API

如果您在建立將裝載于該物件的Windows.UI.Xaml.UIElement物件之前建立DesktopWindowXamlSource物件,裝載Windows.UI.Xaml.UIElement內容的架構可確保所有物件都初始化為相同的執行緒。 如果您在建立將裝載這些物件的DesktopWindowXamlSource物件之前先建立Windows.UI.Xaml.UIElement物件,您必須先呼叫WindowsXamlManager.InitializeForCurrentThread,才能具現化Windows.UI.Xaml.UIElement物件。

因為 DesktopWindowXamlSource 衍生自 IClosable,因此建議您在 .NET) 完成時 將其關閉 (處置 它。

建構函式

DesktopWindowXamlSource()

初始化 DesktopWindowXamlSource 類別的新實例。

屬性

Content

取得或設定您要裝載于傳統型應用程式中的 Windows.UI.Xaml.UIElement 物件。

HasFocus

取得值,指出 DesktopWindowXamlSource 目前在傳統型應用程式中是否有焦點。

方法

Close()

關閉並釋放此 DesktopWindowXamlSource所使用的任何資源。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

NavigateFocus(XamlSourceFocusNavigationRequest)

嘗試以程式設計方式將焦點放在傳統型應用程式中的 DesktopWindowXamlSource

事件

GotFocus

發生于DesktopWindowXamlSource在傳統型應用程式中取得焦點時 (例如,當使用者將焦點放在DesktopWindowXamlSource) 之前的元素時,按下Tab鍵。

TakeFocusRequested

當主桌面應用程式收到要求時,會從 DesktopWindowXamlSource 物件取得焦點 (例如,使用者位於 DesktopWindowXamlSource 中的最後一個可焦點元素上,然後按 Tab) 。

適用於

另請參閱