Skip to content

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

Open
@BaiFeng666

Description

@BaiFeng666

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions