Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

(Winui3/C++) How to correctly initialize the data of the window class (e.g., MainWindow).

Open
#436 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
desktop

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.

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?

Dominant language
PowerShell
Stars
1k
Forks
336
Avg merge
7h 13m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/WindowsAppSDK-Samples

All issues in microsoft/WindowsAppSDK-Samples

Similar issues

More Desktop Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.