DesktopWindowXamlSource DesktopWindowXamlSource DesktopWindowXamlSource DesktopWindowXamlSource Class

Definition

Enables a non-UWP desktop application (for example, a WPF or Windows Forms application) to host UWP controls in any UI element that is associated with a window handle (HWND).

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

public : class DesktopWindowXamlSource : IClosable, IDesktopWindowXamlSource
struct winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource : IClosable, IDesktopWindowXamlSource
public class DesktopWindowXamlSource : IDisposable, IDesktopWindowXamlSource
Public Class DesktopWindowXamlSource Implements IDisposable, IDesktopWindowXamlSource
Attributes

Windows 10 requirements

Device family
Windows Desktop Extension SDK (introduced v10.0.17763.0)
API contract
Windows.UI.Xaml.Hosting.HostingContract (introduced v3)

Remarks

DesktopWindowXamlSource is the main class in the UWP XAML hosting API. This API enables non-UWP desktop applications to host any control that derives from Windows.UI.Xaml.UIElement ) in a UI element that is associated with a window handle (HWND). This API can be used by desktop applications built using WPF, Windows Forms, and the Windows API (Win32). For more information, see Using the UWP XAML hosting API in a desktop application.

DesktopWindowXamlSource can only be used in one top-level window per thread. If you want to host XAML content in multiple top-level windows, each window must be on its own thread.

If you create a DesktopWindowXamlSource object before you create the Windows.UI.Xaml.UIElement objects that will be hosted in it, the framework for hosting Windows.UI.Xaml.UIElement content makes sure all the objects are initialized to the same thread. If you create the Windows.UI.Xaml.UIElement objects before you create the DesktopWindowXamlSource object in which they will be hosted, you must call WindowsXamlManager.InitializeForCurrentThread before you instantiate the Windows.UI.Xaml.UIElement objects.

Because DesktopWindowXamlSource derives from IClosable, so it is recommended that you Close it (Dispose it in .NET) when you’re finished with it.

Constructors

DesktopWindowXamlSource() DesktopWindowXamlSource() DesktopWindowXamlSource() DesktopWindowXamlSource()

Initializes a new instance of the DesktopWindowXamlSource class.

Properties

Content Content Content Content

Gets or sets the Windows.UI.Xaml.UIElement object that you want to host in the desktop application.

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

HasFocus HasFocus HasFocus HasFocus

Gets a value that indicates whether the DesktopWindowXamlSource currently has focus in the desktop application.

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Methods

Close() Close() Close() Close()

Closes and releases any resources used by this DesktopWindowXamlSource.

Dispose() Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

NavigateFocus(XamlSourceFocusNavigationRequest) NavigateFocus(XamlSourceFocusNavigationRequest) NavigateFocus(XamlSourceFocusNavigationRequest) NavigateFocus(XamlSourceFocusNavigationRequest)

Attempts to programmatically give focus to the DesktopWindowXamlSource in the desktop application.

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Events

GotFocus GotFocus GotFocus GotFocus

Occurs when the DesktopWindowXamlSource gets focus in the desktop application (for example, the user presses the Tab key while focus is on the element just before the DesktopWindowXamlSource).

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

TakeFocusRequested TakeFocusRequested TakeFocusRequested TakeFocusRequested

Occurs when the host desktop application receives a request take back focus from the DesktopWindowXamlSource object (for example, the user is on the last focusable element in the DesktopWindowXamlSource and presses Tab).

Note

This API is currently available as a developer preview. Although we encourage you to try out this API in your own prototype code now, we do not recommend that you use it in production code at this time. This API will continue to mature and stabilize in future Windows releases. Microsoft makes no warranties, express or implied, with respect to the information provided here.

See Also