Skip to content

IInitializeWithWindowHelper

HO-COOH edited this page Mar 22, 2026 · 2 revisions

IInitializeWithWindowHelper

Properties (WinUI3 IDL)

Name IsDependencyProperty Description
N/A No corresponding WinUI3Package IDL runtimeclass was found for this component.

A header-only helper for initializing WinRT objects that requires a hwnd.

To use, simply change the namespace winrt to WinUIEssentials of your objects that needs to be initialized, and pass either a HWND or a Microsoft.UI.Xaml.Window to the constructor.

Take FileOpenPicker as an example:

#include <include/IInitializeWithWindowHelper.hpp>

WinUIEssentials::Windows::Storage::Pickers::FileOpenPicker picker{ MainWindow::Hwnd };
//or
WinUIEssentials::Windows::Storage::Pickers::FileOpenPicker picker{ MainWindow::Instance };

//...
picker.PickSingleFileAsync();

Clone this wiki locally