WindowsXamlManager 類別

定義

代表非 Windows 應用程式 SDK(WASDK)桌面應用程式中的 WinUI XAML 框架(例如 WPF 或 Windows Forms 應用程式)。

public ref class WindowsXamlManager sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class WindowsXamlManager final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class WindowsXamlManager : System.IDisposable
Public NotInheritable Class WindowsXamlManager
Implements IDisposable
繼承
Object Platform::Object IInspectable WindowsXamlManager
屬性
實作

範例

這個範例展示了如何在 Win32 應用程式中新增一個包含 XAML 內容的 WASDK 島嶼(該應用程式必須安裝 Windows 應用程式 SDK 執行環境才能執行)。

簡易島應用程式

備註

WindowsXamlManagerWindows 應用程式 SDK XAML 主機 API 的一部分。 此 API 使非 WASDK 桌面應用程式能承載任何來自 Microsoft 的控制項。UI。Xaml.UIElement 在與視窗句柄(HWND)相關聯的 UI 元素中。 此 API 可用於使用 WPF、Windows Forms 及 Windows API(Win32)建置的桌面應用程式。

從 Windows 應用程式 SDK 1.4 到 Windows 應用程式 SDK 1.5 的變更

WASDK 1.4 WASDK 1.5 及以後版本
當執行緒中所有 WindowsXamlManagerDesktopWindowXamlSource 物件都被關閉或銷毀,或該執行緒上的 DispatcherQueue 被關閉時,XAML 執行時會非同步關閉。 XAML 執行時只有在執行緒上的 DispatcherQueue 關閉時才會關閉。
WindowsXamlManager.InitializeForCurrentThread 每次呼叫時都會回傳一個新的物件。 WindowsXamlManager.InitializeForCurrentThread 會回傳同 WindowsXamlManager 一個實例,直到執行緒上的 DispatcherQueue 關閉為止。

方法

名稱 Description
Close()

關閉並非同步釋放 WindowsXamlManager 所使用的任何資源。

Dispose()

執行與釋放、釋放或重設非受控資源相關聯的應用程式定義工作。

GetForCurrentThread()

取得 WindowsXamlManager 與目前執行緒相關的物件(如果有的話)。

InitializeForCurrentThread()

在目前執行緒中初始化非 Windows 應用程式 SDK(WASDK)桌面應用程式(例如 WPF 或 Windows Forms 應用程式)中的 WinUI XAML 框架。

事件

名稱 Description
XamlShutdownCompletedOnThread

當 XAML 執行時在當前執行緒完成關機程序時會發生。

適用於

另請參閱