DataGrid in WinUI3 with c++/Winrt

Harshithraj1871 1,686 Reputation points
2022-10-07T08:51:57.787+00:00

Hi,

We are building a complex table-like experience with WinUI3 using C++/WinRT. Got to know from the documentation that to create a table-like experience WinUI3 gives us DataGrid but this was in Windows Community Toolkit DataGrid under a "C# Island", but we are looking for experience in C++/WinRT. It would be great if you could point me to the right documentation to achieve table-like experience in C++/WinRT.

Developer technologies | Universal Windows Platform (UWP)
Windows development | Windows App SDK
Developer technologies | C++
0 comments No comments
{count} vote

Accepted answer
  1. Anonymous
    2022-10-10T02:00:38.237+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Frist of all, the Windows Community Toolkit is based on C# but is not a Windows Runtime Component, so it's not directly consumable in C++ applications. A possible way to use the DataGrid is to create a C# based project in your solutions, consume that from your C++ app, and then consume the Toolkit via that. Here is the official sample from the Community Toolkit- C# Island in C++/WinRT Sample. And more information about this here: Blank App (WinRT/C++) Can't add nuget package Microsoft.Toolkit.Uwp.UI.Controls · Issue #3704 · CommunityToolkit/WindowsCommunityToolkit · GitHub.

    If you are do not want to use that way, I have to say that you will need to implement a DataGrid on your own in your project just like @michael-hawker said in the Github issue. You could refer to the source code of the DataGrid here: DataGrid-Github.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.