Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1. I want a collection of Person, read it out and fill the listView.
2. Please see "What have you tried". Is it a good idea to continue with WinUI because it seems not good documented for c++?!



MainWindow.xaml

<Grid >
    <ListView x:Name="testView"
              Margin="60,50,0,60"
              Background="Red"
              Width="300"
              HorizontalAlignment="Left">
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid Height="110" Margin="6">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0" Background="Beige">
                        <TextBlock TextWrapping="NoWrap"/>
                        <TextBlock MaxHeight="60"/>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Grid>


MainWindow.xaml.cpp

class Person
	{
		public:
			std::string name;
			std::string description;
	};

	MainWindow::MainWindow()
	{
		InitializeComponent();
	
    }


What I have tried:

I tried a lot of C# examples but i can't find the C++ equivalent. I saw that usually xbind would be the easiest in c# but it seems that it's not supported in WinUI? It drives me a little bit crazy because it's been a few days.
Posted
Updated 20-Mar-22 13:26pm

1 solution

There seems to be quite a few examples. Maybe this will help:
Sample applications for Windows development
Sample applications for Windows development - Windows apps | Microsoft Docs[^]

Here is an overview of WinUI3:
Windows UI Library (WinUI) 3 - Windows apps | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900