https://github.com/sotanakamura/winui3-without-midl
WinUI 3 with C++ and XAML but without MIDL
https://github.com/sotanakamura/winui3-without-midl
cpp windows winui3 without-midl
Last synced: 4 months ago
JSON representation
WinUI 3 with C++ and XAML but without MIDL
- Host: GitHub
- URL: https://github.com/sotanakamura/winui3-without-midl
- Owner: sotanakamura
- License: mit
- Created: 2023-03-03T13:57:40.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-04T06:33:57.000Z (over 2 years ago)
- Last Synced: 2025-05-05T22:48:02.615Z (about 1 year ago)
- Topics: cpp, windows, winui3, without-midl
- Language: C++
- Homepage:
- Size: 20.5 KB
- Stars: 17
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# WinUI 3 with C++ and XAML but without MIDL
You can define WinUI 3 UIs with XAML. Classes reffered in XAML should be Windows runtime classes which you define with MIDL. Creating Windows Runtime classes is a little bit hard. This repositry provides information aboud how to define UIs with XAML but without MIDL.
## Define UIs in C++
See [WinUI 3 in C++ Without XAML](https://github.com/sotanakamura/winui3-without-xaml)
## Define UIs in XAML instead of C++ code
1. Add MainPage.xaml file to define UIs.
```xaml
// MainPage.xaml
Hello World!
```
1. Load XAML file and assign it as a UIElement object.
```cpp
window = Window();
Application::LoadComponent(window, Uri(L"ms-appx:///MainPage.xaml"));
```
## Build and run
You can see a window displaying "Hello World!"
## Note
You need to implement event hundlers and binding in C++ code. If you want to do it in XAML, you need to create Windows Runtime class with MIDL.