microsoft / microsoft/WindowsAppSDK
UI components are not loaded for a runtime component derived from another own runtime component (C++)
@bpulliam is already working on this.
Since Oct 17, 2022.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
The components defined in the XAML part of a C++ runtime component are not loaded during the execution of `InitializeComponent()` if the component uses another, own runtime component as base class.
Also, the handlers of the Loaded/Unloaded events are not called.
The problems do not occur if the XAML component is derived directly from Microsoft.UI.Xaml.Controls.UserControl, for example.
### Steps to reproduce the bug
Download and build the following demo app:
[UnpackagedDemoApp_SDK1_2_prev2.zip](https://github.com/microsoft/WindowsAppSDK/files/9756163/UnpackagedDemoApp_SDK1_2_prev2.zip)
Set a breakpoint in file TestView.xaml.cpp -> Constructor -> `tb.Text(Name());`.
Run the app and click the button.
Check the value of the component `tb`, when the app stops. It is not set to the loaded component but null and the app crashes if you continue. If you set an additional breakpoint in the generated file TestView.xaml.g.hpp -> Connect(...) you can see that the method is never called.
To check the event handler problem remove all breakpoints and comment out the line `tb.Text(Name());`
Set breakpoints within the handlers `ViewBase_Loaded` and `ViewBase_Unloaded` in the file TestView.xaml.cpp.
Run the app. Click the button to load the view. 'ViewBase_Loaded' should be executed, but isn't.
Click the button again to unload the view. 'ViewBase_Unloaded' should be executed, but isn't.
### Expected behavior
Components like the TextBlock element `tb` in the example should be loaded during the execution of `InitializeComponent()` .
Handler of events like Loaded and Unloaded should be executed.
### Screenshots
_No response_
### NuGet package version
1.2.220930.4-preview2
### Packaging type
Unpackaged
### Windows version
Windows 10 version 21H2 (19044, November 2021 Update)
### IDE
Visual Studio 2022, Visual Studio 2019
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.