WPF Create Datagrid/Table If The Data is Dynamically Changes

Olivia Olga 1 Reputation point
2022-04-07T13:38:25.873+00:00

Hello, I am new to Q&A Microsoft, I used to see solutions in Social MSDN and I just know that the page migrated to Q&A.

I have a question. If I have data that will change every time, for example, today I will have 2 products and the program will create 3 tables for each detail.

Product 1
Date | Sales | Refund
1/3/2022 | 3 | 0
2/3/2022 | 4 | 2
3/3/2022 | 3 | 1

Product 2
Date | Sales | Refund
1/3/2022 | 2 | 1
2/3/2022 | 5 | 0
3/3/2022 | 3 | 2

Tomorrow, there will be 4 products and the program should create 4 tables.

Product 1
Date | Sales | Refund
1/3/2022 | 3 | 0
2/3/2022 | 4 | 2
3/3/2022 | 3 | 1
4/3/2022 | 2 | 1

Product 2
Date | Sales | Refund
1/3/2022 | 2 | 1
2/3/2022 | 5 | 0
3/3/2022 | 3 | 2
4/4/2022 | 2 | 0

Product 3
Date | Sales | Refund
1/3/2022 | 0 | 0
2/3/2022 | 0 | 0
3/3/2022 | 0 | 0
4/4/2022 | 2 | 0

Product 4
Date | Sales | Refund
1/3/2022 | 0 | 0
2/3/2022 | 0 | 0
3/3/2022 | 0 | 0
4/4/2022 | 4 | 0

In WPF, datagrid should be declared first, but how if I have dynamic data? Can WPF create dynamic tables too? Could you provide me with some example code? Thank you.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,010 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
814 questions
{count} votes

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.