5#include <ShObjIdl_core.h> 
    6#include <winrt/Windows.UI.Xaml.Controls.Primitives.h> 
   17    auto SetXamlRoot(winrt::Windows::Foundation::IInspectable obj, cppxaml::xaml::XamlRoot root) {
 
   18        if (
auto fe = obj.try_as<winrt::Windows::UI::Xaml::FrameworkElement>()) {
 
   19            return fe.XamlRoot(root);
 
   21        else if (
auto fb = obj.try_as<winrt::Windows::UI::Xaml::Controls::Primitives::FlyoutBase>()) {
 
   22            return fb.XamlRoot(root);
 
   24        throw winrt::hresult_error(E_NOINTERFACE);
 
   36    template<
typename TWindow>
 
   39        !std::is_same_v<TWindow, cppxaml::XamlWindow*> &&
 
   40        !std::is_same_v<TWindow, HWND>>
 
   46        if (
auto iww = obj.try_as<IInitializeWithWindow>()) {
 
   48            w.as<IWindowNative>()->get_WindowHandle(&hwnd);
 
   49            iww->Initialize(hwnd);
 
   51        else if (
auto window = w.as<cppxaml::xaml::Window>()) {
 
   52            obj.XamlRoot(window.Content().XamlRoot());
 
   57            SetXamlRoot(obj, w.XamlRoot());
 
   69        if (
auto iww = obj.try_as<IInitializeWithWindow>()) {
 
   70            iww->Initialize(hwnd);
 
   83            SetXamlRoot(obj, xw->
GetUIElement<cppxaml::xaml::FrameworkElement>().XamlRoot());
 
   95    template<
typename TUIElement, 
typename TWindow>
 
   97    std::enable_if_t<std::is_assignable_v<cppxaml::xaml::UIElement, TUIElement> &&
 
   98        !std::is_same_v<TWindow, const cppxaml::XamlWindow*>, 
void>
 
The main CppXAML namespace.
 
void InitializeWithWindow(winrt::Windows::Foundation::IInspectable obj, TWindow w)
Initializes an object with a window-like object.
Definition: InitializeWithWindow.h:44
 
Implements an HWND based host for XAML Islands. You can create a XamlWindow from one of three overloa...
Definition: XamlWindow.h:54
 
HWND hwnd() const
returns the HWND backing the XamlWindow.
Definition: XamlWindow.h:87
 
T GetUIElement() const
returns the XAML UI that the XamlWindow was created with.
Definition: XamlWindow.h:97