CppXAML
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cppxaml::XamlWindow Struct Reference

Implements an HWND based host for XAML Islands. You can create a XamlWindow from one of three overloads of XamlWindow::Make. More...

#include <cppxaml/XamlWindow.h>

Public Member Functions

HWND hwnd () const
 returns the HWND backing the XamlWindow.
 
template<typename T = winrt::Windows::UI::Xaml::UIElement>
GetUIElement () const
 returns the XAML UI that the XamlWindow was created with.
 
std::wstring_view Id () const
 returns the window's id
 
HWND Create (wchar_t const *szTitle, DWORD style, HWND parent=nullptr, int width=CW_USEDEFAULT, int height=CW_USEDEFAULT, int nCmdShow=SW_NORMAL)
 Call this function to create the actual window. Afterwards, you will call XamlWindow::RunLoop to process window messages.
 
void SetAcceleratorTable (HACCEL acc)
 
AppControllerController () const
 
int RunLoop ()
 

Static Public Member Functions

template<typename TUIElement >
static XamlWindowMake (std::wstring_view id, AppController *controller=nullptr)
 Creates a window that hosts a XAML UI element.
 
static XamlWindowMake (std::wstring_view id, std::wstring_view markup, AppController *c=nullptr)
 Creates a window that hosts XAML UI, based on some markup provided as an input parameter.
 
static XamlWindowMake (std::wstring_view id, winrt::Windows::UI::Xaml::UIElement(*getUI)(const XamlWindow &), AppController *c=nullptr)
 Creates a window that hosts XAML UI. The UI will be provided by the app.
 
static XamlWindowGet (std::wstring_view id)
 returns the XamlWindow corresponding to the id.
 

Detailed Description

Implements an HWND based host for XAML Islands. You can create a XamlWindow from one of three overloads of XamlWindow::Make.

Member Function Documentation

◆ Controller()

AppController * cppxaml::XamlWindow::Controller ( ) const
inline
Returns

◆ Create()

HWND cppxaml::XamlWindow::Create ( wchar_t const *  szTitle,
DWORD  style,
HWND  parent = nullptr,
int  width = CW_USEDEFAULT,
int  height = CW_USEDEFAULT,
int  nCmdShow = SW_NORMAL 
)
inline

Call this function to create the actual window. Afterwards, you will call XamlWindow::RunLoop to process window messages.

Parameters
szTitleThe window title.
styleThe window style. See Window styles and CreateWindow.
parentoptional parent window.
widthoptional window width.
heightoptional window height.
nCmdShowControls how the window is shown. See ShowWindow.
Returns

◆ Get()

static XamlWindow & cppxaml::XamlWindow::Get ( std::wstring_view  id)
inlinestatic

returns the XamlWindow corresponding to the id.

Parameters
id
Returns

◆ GetUIElement()

template<typename T = winrt::Windows::UI::Xaml::UIElement>
T cppxaml::XamlWindow::GetUIElement ( ) const
inline

returns the XAML UI that the XamlWindow was created with.

Template Parameters
TXAML type to cast to; defaults to UIElement.
Returns

◆ hwnd()

HWND cppxaml::XamlWindow::hwnd ( ) const
inline

returns the HWND backing the XamlWindow.

Returns

◆ Id()

std::wstring_view cppxaml::XamlWindow::Id ( ) const
inline

returns the window's id

Returns

◆ Make() [1/3]

template<typename TUIElement >
static XamlWindow & cppxaml::XamlWindow::Make ( std::wstring_view  id,
AppController controller = nullptr 
)
inlinestatic

Creates a window that hosts a XAML UI element.

Template Parameters
TUIElementthe XAML type to instantiate, usually a subclass of Page; this is usually defined by a separate WinRT Runtime component project, that the XAML Islands project references via C++/WinRT.
Parameters
id
controller
Returns

Usage:

auto& mainWindow = cppxaml::XamlWindow::Make<MarkupSample::MainPage>(L"MarkupSample", &controller);

◆ Make() [2/3]

static XamlWindow & cppxaml::XamlWindow::Make ( std::wstring_view  id,
std::wstring_view  markup,
AppController c = nullptr 
)
inlinestatic

Creates a window that hosts XAML UI, based on some markup provided as an input parameter.

Parameters
id
markupXAML markup string to use to create the UI.
c
Returns

Usage:

auto& xw = cppxaml::XamlWindow::Make(L"MyPage", LR"(
<StackPanel>
<TextBlock>Hello</TextBlock>
</StackPanel>)", &controller);
static XamlWindow & Make(std::wstring_view id, AppController *controller=nullptr)
Creates a window that hosts a XAML UI element.
Definition: XamlWindow.h:114

◆ Make() [3/3]

static XamlWindow & cppxaml::XamlWindow::Make ( std::wstring_view  id,
winrt::Windows::UI::Xaml::UIElement(*)(const XamlWindow &)  getUI,
AppController c = nullptr 
)
inlinestatic

Creates a window that hosts XAML UI. The UI will be provided by the app.

Parameters
id
getUIApp-provided function to create UI. This can e.g. instantiate XAML types programmatically.
c
Returns

Usage:

auto& xw = cppxaml::XamlWindow::Make(L"Foo", [](auto&...) { return winrt::Windows::UI::Xaml::Controls::Button(); });

◆ RunLoop()

int cppxaml::XamlWindow::RunLoop ( )
inline
Returns

◆ SetAcceleratorTable()

void cppxaml::XamlWindow::SetAcceleratorTable ( HACCEL  acc)
inline
Parameters
acc

The documentation for this struct was generated from the following file: