microsoft / microsoft/WindowsAppSDK-Samples
(Winui3/C++) How to correctly initialize the data of the window class (e.g., MainWindow).
Open
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1k
- Forks
- 335
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 8
Description
C++ WinUI 3 examples are really scarce.
I need to initialize the following code:
sourceList().ItemsSource(sourceArray);
struct MainWindow : MainWindowT<MainWindow>
{
MainWindow()
{
// Xaml objects should not call InitializeComponent during construction.
// See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
//When I initialize here, an error occurs. I think it's because the component is not fully initialized.
sourceList().ItemsSource(sourceArray);
}
...
Where should I elegantly and right implement the initialization of this code?
Contributor guide
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.
Research direction
Start with the MainWindow constructor and the referenced C++/WinRT InitializeComponent guidance. Determine the appropriate post-initialization point for sourceList().ItemsSource(sourceArray), then verify that the window initializes without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100