WinUI Gridview within MainWindow

youki 996 Reputation points
2022-03-06T14:53:18.217+00:00

Hello,
I try to start with c++ and also with WinUI. I've never worked with XAML before. I already have the XAML Controls Gallery and tried a few examples on MSDN.

I want to add a gridview (each row under each other) and try to add the rows.
I tried a few examples but i can't figure it out, how to start and what to take.

  1. Should i use a binding or add it programmatically? (I want the ability to add and delete rows)
  2. I have a menu bar on top and i also want to add an other gridview later, so i use a grid as a container for all?
  3. I think i will load the data from a XML to a vector of objects and then try to get it to the grid?
  4. What is the simplest (and best) solution for getting it done within the MainWindow, any links or code please to get into it?!
     <Grid >
            <muxc:MenuBar VerticalAlignment="Top">
                <muxc:MenuBarItem Title="1"/>
                <muxc:MenuBarItem Title="2"/>
                <muxc:MenuBarItem Title="3"/>
                <muxc:MenuBarItem Title="4"/>
                <muxc:MenuBarItem Title="5"/>
                <muxc:MenuBarItem Title="6"/>
            </muxc:MenuBar>
            <TextBox x:Name="tbTest" HorizontalAlignment="Center" VerticalAlignment="Center" Text="test"></TextBox>
    
        </Grid>
    
    class MyObject
    {
    public:
    string name;
    string description;
    }; MainWindow::MainWindow()
    {
    InitializeComponent(); vector<MyObject> test; MyObject c;
    c.name = "Rick";
    c.description = "Man"; test.push_back(c); c.name = "Diana";
    c.description = "Woman"; test.push_back(c); } Regards
Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
725 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,526 questions
{count} votes

Accepted answer
  1. Castorix31 81,636 Reputation points
    2022-03-06T16:36:04.777+00:00

    You can see the MS sample Photo Editor C++/WinRT sample application which uses GridView and other controls
    But it is complicated
    It is a lot simpler to do it in C#, by copying/adapting code from XAML Controls Gallery or any MSDN sample (most of them are in C#)


0 additional answers

Sort by: Most helpful